aboutsummaryrefslogtreecommitdiffstats
path: root/lualib/lua_maps.lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-04-09 12:42:37 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-04-09 12:42:37 +0100
commita6223eecc74c5ecbe48ff3265bb4c9b62c0c3dd7 (patch)
treeda213d37c4ae6d2a82395129d714677d433d95e4 /lualib/lua_maps.lua
parent46f70b9b36d859a3df113d4286d2b40ff11b0632 (diff)
downloadrspamd-a6223eecc74c5ecbe48ff3265bb4c9b62c0c3dd7.tar.gz
rspamd-a6223eecc74c5ecbe48ff3265bb4c9b62c0c3dd7.zip
[Feature] Lua_maps: Allow static regexp and glob maps
Diffstat (limited to 'lualib/lua_maps.lua')
-rw-r--r--lualib/lua_maps.lua36
1 files changed, 26 insertions, 10 deletions
diff --git a/lualib/lua_maps.lua b/lualib/lua_maps.lua
index c8cffa3c8..a21a60f4f 100644
--- a/lualib/lua_maps.lua
+++ b/lualib/lua_maps.lua
@@ -95,16 +95,32 @@ local function rspamd_map_add_from_ucl(opt, mtype, description)
end
end
elseif mtype == 'regexp' or mtype == 'glob' then
- -- Plain table
- local map = rspamd_config:add_map{
- type = mtype,
- description = description,
- url = opt,
- }
- if map then
- ret.__data = map
- setmetatable(ret, ret_mt)
- return ret
+ if string.find(opt[1], '^/%a') or string.find(opt[1], '^http') then
+ -- Plain table
+ local map = rspamd_config:add_map{
+ type = mtype,
+ description = description,
+ url = opt,
+ }
+ if map then
+ ret.__data = map
+ setmetatable(ret, ret_mt)
+ return ret
+ end
+ else
+ local map = rspamd_config:add_map{
+ type = mtype,
+ description = description,
+ url = {
+ url = 'static',
+ data = opt,
+ }
+ }
+ if map then
+ ret.__data = map
+ setmetatable(ret, ret_mt)
+ return ret
+ end
end
else
if string.find(opt[1], '^/%a') or string.find(opt[1], '^http') then