summaryrefslogtreecommitdiffstats
path: root/src/plugins/lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2010-05-14 19:01:37 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2010-05-14 19:01:37 +0400
commitb5da363b902196f93b1ba3cd01d85394e26fb5b5 (patch)
tree6923e8c95b5e29a89d9fbb5b7891db38d024d5a9 /src/plugins/lua
parent9b5d1aa9540e46fb2f820d01dbb63c035ab0af18 (diff)
downloadrspamd-b5da363b902196f93b1ba3cd01d85394e26fb5b5.tar.gz
rspamd-b5da363b902196f93b1ba3cd01d85394e26fb5b5.zip
* Add more logic to fuzzy mappings
* Improve logic of received_rbl plugin to support different symbols for different rbls
Diffstat (limited to 'src/plugins/lua')
-rw-r--r--src/plugins/lua/received_rbl.lua30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/plugins/lua/received_rbl.lua b/src/plugins/lua/received_rbl.lua
index 045b56e7f..304678613 100644
--- a/src/plugins/lua/received_rbl.lua
+++ b/src/plugins/lua/received_rbl.lua
@@ -13,8 +13,24 @@ local rbls = {}
function dns_cb(task, to_resolve, results, err)
if results then
- local _,_,rbl = string.find(to_resolve, '%d+%.%d+%.%d+%.%d+%.(.+)')
- task:insert_result(metric, symbol, 1, rbl)
+ local _,_,o4,o3,o2,o1,in_rbl = string.find(to_resolve, '(%d+)%.(%d+)%.(%d+)%.(%d+)%.(.+)')
+ local ip = o1 .. '.' .. o2 .. '.' .. o3 .. '.' .. o4
+ -- Find incoming rbl in rbls list
+ for _,rbl in ipairs(rbls) do
+ if rbl == in_rbl then
+ task:insert_result(metric, symbol, 1, rbl .. ': ' .. ip)
+ else
+ local s, _ = string.find(rbl, in_rbl)
+ if s then
+ s, _ = string.find(rbl, ':')
+ if s then
+ task:insert_result(metric, string.sub(rbl, s + 1, -1), 1, ip)
+ else
+ task:insert_result(metric, symbol, 1, rbl .. ': ' .. ip)
+ end
+ end
+ end
+ end
end
end
@@ -25,7 +41,15 @@ function received_cb (task)
if k == 'real_ip' then
local _,_,o1,o2,o3,o4 = string.find(v, '(%d+)%.(%d+)%.(%d+)%.(%d+)')
for _,rbl in ipairs(rbls) do
- rbl_str = o4 .. '.' .. o3 .. '.' .. o2 .. '.' .. o1 .. '.' .. rbl
+ local rbl_str = ''
+ local rb_s,_ = string.find(rbl, ':')
+ if rb_s then
+ -- We have rbl in form some_rbl:SYMBOL, so get first part
+ local actual_rbl = string.sub(rbl, 1, rb_s - 1)
+ rbl_str = o4 .. '.' .. o3 .. '.' .. o2 .. '.' .. o1 .. '.' .. actual_rbl
+ else
+ rbl_str = o4 .. '.' .. o3 .. '.' .. o2 .. '.' .. o1 .. '.' .. rbl
+ end
task:resolve_dns_a(rbl_str, 'dns_cb')
end
end