From bf864128960897e0872855743e25ad1267eeca6b Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 29 May 2019 18:46:19 +0100 Subject: [PATCH] [Fix] Do not output rbl suffix in symbol option --- src/plugins/lua/rbl.lua | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/plugins/lua/rbl.lua b/src/plugins/lua/rbl.lua index 0b53a4ca1..eb2e3ed82 100644 --- a/src/plugins/lua/rbl.lua +++ b/src/plugins/lua/rbl.lua @@ -156,12 +156,12 @@ local function gen_check_rcvd_conditions(rbl, received_total) end end -local function rbl_dns_process(task, rbl, to_resolve, results, err) +local function rbl_dns_process(task, rbl, to_resolve, results, err, orig) if err and (err ~= 'requested record is not found' and err ~= 'no records with this name') then rspamd_logger.infox(task, 'error looking up %s: %s', to_resolve, err) task:insert_result(rbl.symbol .. '_FAIL', 1, string.format('%s:%s', - to_resolve, err)) + orig, err)) return end @@ -177,7 +177,7 @@ local function rbl_dns_process(task, rbl, to_resolve, results, err) end if rbl.returncodes == nil and rbl.symbol ~= nil then - task:insert_result(rbl.symbol, 1, to_resolve) + task:insert_result(rbl.symbol, 1, orig) return end @@ -190,14 +190,14 @@ local function rbl_dns_process(task, rbl, to_resolve, results, err) for _,v in ipairs(i) do if string.find(ipstr, '^' .. v .. '$') then foundrc = true - task:insert_result(s, 1, to_resolve .. ' : ' .. ipstr) + task:insert_result(s, 1, orig .. ' : ' .. ipstr) break end end end if not foundrc then if rbl.unknown and rbl.symbol then - task:insert_result(rbl.symbol, 1, to_resolve) + task:insert_result(rbl.symbol, 1, orig) else rspamd_logger.errx(task, 'RBL %1 returned unknown result: %2', rbl.rbl, ipstr) @@ -219,11 +219,13 @@ local function gen_rbl_callback(rule) requests_table[req].forced = true end else + local orign = maybe_make_hash(req, rule) local nreq = { forced = forced, n = string.format('%s.%s', - maybe_make_hash(req, rule), - rule.rbl) + orign, + rule.rbl), + orig = orign } requests_table[req] = nreq end @@ -429,8 +431,10 @@ local function gen_rbl_callback(rule) -- DNS requests to issue (might be hashed afterwards) local dns_req = {} - local function rbl_dns_callback(_, to_resolve, results, err) - rbl_dns_process(task, rule, to_resolve, results, err) + local function gen_rbl_dns_callback(orig) + return function(_, to_resolve, results, err) + rbl_dns_process(task, rule, to_resolve, results, err, orig) + end end -- Execute functions pipeline @@ -451,7 +455,7 @@ local function gen_rbl_callback(rule) r:resolve_a({ task = task, name = p.n, - callback = rbl_dns_callback, + callback = gen_rbl_dns_callback(p.orig), forced = p.forced }) else -- 2.39.5