diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-11-24 13:30:01 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-11-24 13:30:01 +0000 |
commit | 18b681e68af2bf46d1b153d910ae65109f148158 (patch) | |
tree | 06f860320b18f948938073edc64281b30e2c9dad /src/lua | |
parent | 0bdae52153a2bb591187015adbad935f65daa45d (diff) | |
download | rspamd-18b681e68af2bf46d1b153d910ae65109f148158.tar.gz rspamd-18b681e68af2bf46d1b153d910ae65109f148158.zip |
[Fix] Fix static IP maps
Diffstat (limited to 'src/lua')
-rw-r--r-- | src/lua/lua_map.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/lua/lua_map.c b/src/lua/lua_map.c index 796c74e14..1ed4aff7d 100644 --- a/src/lua/lua_map.c +++ b/src/lua/lua_map.c @@ -158,6 +158,7 @@ lua_config_radix_from_config (lua_State *L) const gchar *mname, *optname; const ucl_object_t *obj; struct rspamd_lua_map *map, **pmap; + static const char fill_ptr[] = "1"; if (!cfg) { return luaL_error (L, "invalid arguments"); @@ -174,8 +175,25 @@ lua_config_radix_from_config (lua_State *L) 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, - TRUE); + + if (ucl_object_type (obj) == UCL_STRING) { + radix_add_generic_iplist (ucl_obj_tostring (obj), &map->data.radix, + TRUE); + } + else { + ucl_object_iter_t it = NULL; + const ucl_object_t *cur; + + map->data.radix = radix_create_compressed (); + + while ((cur = ucl_object_iterate (obj, &it, true)) != NULL) { + if (ucl_object_type (cur) == UCL_STRING) { + rspamd_radix_add_iplist (ucl_object_tostring (cur), + ",;", map->data.radix, fill_ptr, TRUE); + } + } + } + pmap = lua_newuserdata (L, sizeof (void *)); *pmap = map; rspamd_lua_setclass (L, "rspamd{map}", -1); |