diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2010-12-20 22:09:16 +0300 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2010-12-20 22:09:16 +0300 |
commit | b8211fbcc8f7de342d4a0176bedf182e1f37397d (patch) | |
tree | fb5922ce974af9572564f28eaf9ae8798b740e4c /src/plugins/lua/multimap.lua | |
parent | 90b983f151edcb747b86363d30f2101a9b060045 (diff) | |
download | rspamd-b8211fbcc8f7de342d4a0176bedf182e1f37397d.tar.gz rspamd-b8211fbcc8f7de342d4a0176bedf182e1f37397d.zip |
* Introduce new system of configuration checks:
- now symbols inside metrics definition must be inside rules as well
- symbols may be virtual (e.g. when module can insert several symbols inside callback)
- symbols may be pure callbacks (when symbol's name is unknown and depends on conditions)
* Module 'emails' is removed as it is not used in the current rspamd
MANY fixes to sample config files
Diffstat (limited to 'src/plugins/lua/multimap.lua')
-rw-r--r-- | src/plugins/lua/multimap.lua | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/plugins/lua/multimap.lua b/src/plugins/lua/multimap.lua index e4ba9a4fc..97f122c48 100644 --- a/src/plugins/lua/multimap.lua +++ b/src/plugins/lua/multimap.lua @@ -89,7 +89,7 @@ function add_rule(params) local _,_,name,value = string.find(param, '(%w+)%s*=%s*(.+)') if not name or not value then rspamd_logger:err('invalid rule: '..param) - return 0 + return nil end if name == 'type' then if value == 'ip' then @@ -100,7 +100,7 @@ function add_rule(params) newrule['type'] = 'header' else rspamd_logger:err('invalid rule type: '.. value) - return 0 + return nil end elseif name == 'header' then newrule['header'] = value @@ -112,13 +112,13 @@ function add_rule(params) newrule['symbol'] = value else rspamd_logger:err('invalid rule option: '.. name) - return 0 + return nil end end if not newrule['symbol'] or not newrule['map'] or not newrule['symbol'] then rspamd_logger:err('incomplete rule') - return 0 + return nil end if newrule['type'] == 'ip' then newrule['ips'] = rspamd_config:add_radix_map (newrule['map']) @@ -126,7 +126,7 @@ function add_rule(params) newrule['hash'] = rspamd_config:add_hash_map (newrule['map']) end table.insert(rules, newrule) - return 1 + return newrule end -- Registration @@ -139,14 +139,20 @@ if opts then if type(strrules) == 'table' then for _,value in ipairs(strrules) do local params = split(value, ',') - if not add_rule (params) then + local rule = add_rule (params) + if not rule then rspamd_logger:err('cannot add rule: "'..value..'"') + else + rspamd_config:register_virtual_symbol(rule['symbol'], 1.0) end end elseif type(strrules) == 'string' then local params = split(strrules, ',') - if not add_rule (params) then + local rule = add_rule (params) + if not rule then rspamd_logger:err('cannot add rule: "'..strrules..'"') + else + rspamd_config:register_virtual_symbol(rule['symbol'], 1.0) end end end @@ -154,5 +160,5 @@ end if table.maxn(rules) > 0 then -- add fake symbol to check all maps inside a single callback - rspamd_config:register_symbol('MULTIMAP', 1.0, 'check_multimap') + rspamd_config:register_callback_symbol('MULTIMAP', 1.0, 'check_multimap') end |