diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-09-14 17:10:18 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-09-14 17:10:18 +0100 |
commit | 4db25f6c3fe5d0c52cd5679e40996f5956ac87e2 (patch) | |
tree | bb05caae174de8ae2c1c12ade9b09a5c31b12320 | |
parent | 4ce9dbece67d8497ea2b703d6e966aba71aceb18 (diff) | |
download | rspamd-4db25f6c3fe5d0c52cd5679e40996f5956ac87e2.tar.gz rspamd-4db25f6c3fe5d0c52cd5679e40996f5956ac87e2.zip |
[Feature] Support multi flag in regexp and glob maps
-rw-r--r-- | src/plugins/lua/multimap.lua | 47 |
1 files changed, 36 insertions, 11 deletions
diff --git a/src/plugins/lua/multimap.lua b/src/plugins/lua/multimap.lua index 909260681..34bb69d26 100644 --- a/src/plugins/lua/multimap.lua +++ b/src/plugins/lua/multimap.lua @@ -438,8 +438,17 @@ local function multimap_callback(task, rule) end if ret then - callback(ret) + if type(ret) == 'table' then + for _,elt in ipairs(ret) do + callback(elt) + end + + ret = true + else + callback(ret) + end end + return ret end @@ -980,17 +989,33 @@ local function add_multimap_rule(key, newrule) end else if newrule['regexp'] then - newrule['hash'] = rspamd_config:add_map ({ - url = newrule['map'], - description = newrule['description'], - type = 'regexp' - }) + if newrule['multi'] then + newrule['hash'] = rspamd_config:add_map ({ + url = newrule['map'], + description = newrule['description'], + type = 'regexp_multi' + }) + else + newrule['hash'] = rspamd_config:add_map ({ + url = newrule['map'], + description = newrule['description'], + type = 'regexp' + }) + end elseif newrule['glob'] then - newrule['hash'] = rspamd_config:add_map ({ - url = newrule['map'], - description = newrule['description'], - type = 'glob' - }) + if newrule['multi'] then + newrule['hash'] = rspamd_config:add_map ({ + url = newrule['map'], + description = newrule['description'], + type = 'glob_multi' + }) + else + newrule['hash'] = rspamd_config:add_map ({ + url = newrule['map'], + description = newrule['description'], + type = 'glob' + }) + end else newrule['hash'] = rspamd_config:add_map ({ url = newrule['map'], |