From e4b356ae8daf14464901ba4ba785ffd83ce08236 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 21 Nov 2013 14:46:46 +0000 Subject: [PATCH] Fix rbl module registration. --- src/plugins/lua/multimap.lua | 20 +++++++++----------- src/plugins/lua/rbl.lua | 6 +++--- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/plugins/lua/multimap.lua b/src/plugins/lua/multimap.lua index f3d3ef205..229d594cf 100644 --- a/src/plugins/lua/multimap.lua +++ b/src/plugins/lua/multimap.lua @@ -3,14 +3,7 @@ local rules = {} local function ip_to_rbl(ip, rbl) - octets = ip:inversed_str_octets() - local str = '' - for _,o in ipairs(octets) do - str = str .. o .. '.' - end - str = str .. rbl - - return str + return table.concat(ip:inversed_str_octets(), ".") .. '.' .. rbl end local function check_multimap(task) @@ -73,9 +66,14 @@ local function check_multimap(task) end elseif rule['type'] == 'dnsbl' then local ip = task:get_from_ip() - if ip then - task:get_resolver():resolve_a(task:get_session(), task:get_mempool(), - ip_to_rbl(ip, rule['map']), multimap_rbl_cb, rule['map']) + if ip and ip ~= "0.0.0.0" then + if ip:get_version() == 6 and rule['ipv6'] then + task:get_resolver():resolve_a(task:get_session(), task:get_mempool(), + ip_to_rbl(ip, rule['map']), multimap_rbl_cb, rule['map']) + elseif ip:get_version() == 4 then + task:get_resolver():resolve_a(task:get_session(), task:get_mempool(), + ip_to_rbl(ip, rule['map']), multimap_rbl_cb, rule['map']) + end end elseif rule['type'] == 'rcpt' then -- First try to get rcpt field diff --git a/src/plugins/lua/rbl.lua b/src/plugins/lua/rbl.lua index 946e3b367..8067d14f1 100644 --- a/src/plugins/lua/rbl.lua +++ b/src/plugins/lua/rbl.lua @@ -27,7 +27,7 @@ local function rbl_cb (task) end task:inc_dns_req() end - + local rip = task:get_from_ip() if(rip ~= "0.0.0.0") then for _,rbl in pairs(rbls) do @@ -93,6 +93,6 @@ for key,rbl in pairs(opts['rbls']) do if type(rspamd_config.get_api_version) ~= 'nil' then rspamd_config:register_virtual_symbol(rbl['symbol'], 1) end - table.insert(rbls, {symbol = rbl['symbol'], rbl = rbl['rbl'], ipv6 = rbl['ipv6'], ipv4 = rbl['ipv4'], received = rbl['received'], from = rbl['from']}) - rspamd_config:register_symbol(rbl['symbol'], 1.0, rbl_cb) + table.insert(rbls, rbl) end +rspamd_config:register_callback_symbol_priority('RBL', 1.0, -1, rbl_cb) -- 2.39.5