Przeglądaj źródła

[Minor] Add flag for embedded maps

tags/1.2.0
Vsevolod Stakhov 8 lat temu
rodzic
commit
b4ba6f65a0
2 zmienionych plików z 12 dodań i 3 usunięć
  1. 3
    0
      src/lua/lua_common.h
  2. 9
    3
      src/lua/lua_map.c

+ 3
- 0
src/lua/lua_common.h Wyświetl plik

@@ -93,9 +93,12 @@ enum rspamd_lua_map_type {
RSPAMD_LUA_MAP_CALLBACK
};

#define RSPAMD_LUA_MAP_FLAG_EMBEDDED (1 << 0)

struct rspamd_lua_map {
struct rspamd_map *map;
enum rspamd_lua_map_type type;
guint flags;

union {
struct radix_tree_compressed *radix;

+ 9
- 3
src/lua/lua_map.c Wyświetl plik

@@ -173,6 +173,7 @@ lua_config_radix_from_config (lua_State *L)
map->data.radix = radix_create_compressed ();
map->type = RSPAMD_LUA_MAP_RADIX;
map->data.radix = radix_create_compressed ();
map->flags |= RSPAMD_LUA_MAP_FLAG_EMBEDDED;
radix_add_generic_iplist (ucl_obj_tostring (obj), &map->data.radix);
pmap = lua_newuserdata (L, sizeof (void *));
*pmap = map;
@@ -507,7 +508,7 @@ lua_map_get_proto (lua_State *L)
const gchar *ret = "undefined";

if (map != NULL) {
if (map->map == NULL) {
if ((map->flags & RSPAMD_LUA_MAP_FLAG_EMBEDDED) || map->map == NULL) {
ret = "embedded";
}
else {
@@ -536,6 +537,11 @@ lua_map_get_sign_key (lua_State *L)
GString *ret = NULL;

if (map != NULL) {
if (map->flags & RSPAMD_LUA_MAP_FLAG_EMBEDDED) {
lua_pushnil (L);

return 1;
}
if (map->map && map->map->trusted_pubkey) {
ret = rspamd_pubkey_print (map->map->trusted_pubkey,
RSPAMD_KEYPAIR_PUBKEY|RSPAMD_KEYPAIR_BASE32);
@@ -568,7 +574,7 @@ lua_map_set_sign_key (lua_State *L)

if (map && pk_str) {

if (!map->map) {
if ((map->flags & RSPAMD_LUA_MAP_FLAG_EMBEDDED) || !map->map) {
return luaL_error (L, "cannot set key for embedded maps");
}

@@ -620,7 +626,7 @@ lua_map_get_uri (lua_State *L)
const gchar *ret = "undefined";

if (map != NULL) {
if (map->map == NULL) {
if ((map->flags & RSPAMD_LUA_MAP_FLAG_EMBEDDED) || map->map == NULL) {
ret = "embedded";
}
else {

Ładowanie…
Anuluj
Zapisz