diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-09-15 18:42:05 +0400 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-09-15 18:42:05 +0400 |
commit | 6b57031f55ef73619b763c98eadb1dbf82494eac (patch) | |
tree | 8a749d0b5c0ac6c331363a7a3ba871666c2f148c /src/plugins/lua | |
parent | e03d0749928abdff045de0bd2eeb21c5989a94c4 (diff) | |
download | rspamd-6b57031f55ef73619b763c98eadb1dbf82494eac.tar.gz rspamd-6b57031f55ef73619b763c98eadb1dbf82494eac.zip |
* Add lua plugin for checking received headers
* Some tunes to lua API
* Fix bug with http maps
* Optimize installation and make custom prefix for configs
Diffstat (limited to 'src/plugins/lua')
-rw-r--r-- | src/plugins/lua/received_rbl.lua | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/plugins/lua/received_rbl.lua b/src/plugins/lua/received_rbl.lua new file mode 100644 index 000000000..bee027f50 --- /dev/null +++ b/src/plugins/lua/received_rbl.lua @@ -0,0 +1,53 @@ +-- This plugin is designed for testing received headers via rbl +-- Configuration: +-- .module 'received_rbl' { +-- rbl = "insecure-bl.rambler.ru"; +-- rbl = "xbl.spamhaus.org"; +-- metric = "default"; +-- symbol = "RECEIVED_RBL"; +-- }; + + +metric = 'default' +symbol = 'RECEIVED_RBL' +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) + end +end + +function received_cb (task) + local recvh = task:get_received_headers() + for _,rh in ipairs(recvh) do + for k,v in pairs(rh) do + 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 + task:resolve_dns_a(rbl_str, 'dns_cb') + end + end + end + end +end + +-- Configuration +local opts = rspamd_config:get_all_opt('received_rbl') +if opts then + for n,v in pairs(opts) do + if n == 'rbl' then + table.insert(rbls, v) + elseif n == 'metric' then + metric = v + elseif n == 'symbol' then + symbol = v + end + end +end + +-- Register symbol's callback +local m = rspamd_config:get_metric(metric) +m:register_symbol(symbol, 1.0, 'received_cb') |