diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2010-07-28 16:26:45 +0400 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2010-07-28 16:26:45 +0400 |
commit | ed827de91c2df33260223be2f248b4a4342066ae (patch) | |
tree | 02b82d8392001ce36b5a94c66faf32fbd540afd8 /src/plugins | |
parent | e21bec8896c0d9455ae1af28a577b6e0c20cc8f6 (diff) | |
download | rspamd-ed827de91c2df33260223be2f248b4a4342066ae.tar.gz rspamd-ed827de91c2df33260223be2f248b4a4342066ae.zip |
* Add ability to check dns black lists by multimap module
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/lua/multimap.lua | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/plugins/lua/multimap.lua b/src/plugins/lua/multimap.lua index 18d5c503e..6e949b721 100644 --- a/src/plugins/lua/multimap.lua +++ b/src/plugins/lua/multimap.lua @@ -27,6 +27,19 @@ function split(str, delim, maxNb) return result end +function rbl_cb(task, to_resolve, results, err) + if results then + local _,_,o4,o3,o2,o1,in_rbl = string.find(to_resolve, '(%d+)%.(%d+)%.(%d+)%.(%d+)%.(.+)') + -- Get corresponding rule by rbl name + for _,rule in ipairs(rules) do + if rule['map'] == in_rbl then + task:insert_result(rule['symbol'], 1, rule['map']) + return + end + end + end +end + function check_multimap(task) for _,rule in ipairs(rules) do if rule['type'] == 'ip' then @@ -53,7 +66,14 @@ function check_multimap(task) end end end - end + elseif rule['type'] == 'dnsbl' then + local ip = task:get_from_ip() + if ip then + local _,_,o1,o2,o3,o4 = string.find(ip, '(%d+)%.(%d+)%.(%d+)%.(%d+)') + local rbl_str = o4 .. '.' .. o3 .. '.' .. o2 .. '.' .. o1 .. '.' .. rule['map'] + task:resolve_dns_a(rbl_str, 'rbl_cb') + end + end end end @@ -74,6 +94,8 @@ function add_rule(params) if name == 'type' then if value == 'ip' then newrule['type'] = 'ip' + elseif value == 'dnsbl' then + newrule['type'] = 'dnsbl' elseif value == 'header' then newrule['type'] = 'header' else @@ -100,7 +122,7 @@ function add_rule(params) end if newrule['type'] == 'ip' then newrule['ips'] = rspamd_config:add_radix_map (newrule['map']) - else + elseif newrule['type'] == 'header' then newrule['hash'] = rspamd_config:add_hash_map (newrule['map']) end table.insert(rules, newrule) |