|
|
@@ -720,45 +720,40 @@ local function reputation_dns_get_token(task, rule, token, continuation_cb) |
|
|
|
local key = gen_token_key(token, rule) |
|
|
|
local dns_name = key .. '.' .. rule.backend.config.list |
|
|
|
|
|
|
|
local function dns_callback(_, to_resolve, results, err) |
|
|
|
if err and (err ~= 'requested record is not found' and err ~= 'no records with this name') then |
|
|
|
rspamd_logger.errx(task, 'error looking up %s: %s', to_resolve, err) |
|
|
|
end |
|
|
|
if not results then |
|
|
|
lua_util.debugm(N, task, 'DNS RESPONSE: label=%1 results=%2 error=%3 list=%4', |
|
|
|
to_resolve, false, err, rule.backend.config.list) |
|
|
|
else |
|
|
|
lua_util.debugm(N, task, 'DNS RESPONSE: label=%1 results=%2 error=%3 list=%4', |
|
|
|
to_resolve, true, err, rule.backend.config.list) |
|
|
|
end |
|
|
|
|
|
|
|
-- Now split tokens to list of values |
|
|
|
if not err and results then |
|
|
|
local values = {} |
|
|
|
-- Format: key1=num1;key2=num2...keyn=numn |
|
|
|
fun.each(function(e) |
|
|
|
local vals = lua_util.rspamd_str_split(e, "=") |
|
|
|
if vals and #vals == 2 then |
|
|
|
local nv = tonumber(vals[2]) |
|
|
|
if nv then |
|
|
|
values[vals[1]] = nv |
|
|
|
end |
|
|
|
end |
|
|
|
end, |
|
|
|
lua_util.rspamd_str_split(results[1], ";")) |
|
|
|
continuation_cb(nil, to_resolve, values) |
|
|
|
else |
|
|
|
continuation_cb(err, to_resolve, nil) |
|
|
|
end |
|
|
|
|
|
|
|
task:inc_dns_req() |
|
|
|
end |
|
|
|
r:resolve_a({ |
|
|
|
local is_ok, results = r:resolve_a({ |
|
|
|
task = task, |
|
|
|
name = dns_name, |
|
|
|
callback = dns_callback, |
|
|
|
forced = true, |
|
|
|
}) |
|
|
|
|
|
|
|
if not is_ok and (results ~= 'requested record is not found' and results ~= 'no records with this name') then |
|
|
|
rspamd_logger.errx(task, 'error looking up %s: %s', dns_name, results) |
|
|
|
end |
|
|
|
|
|
|
|
lua_util.debugm(N, task, 'DNS RESPONSE: label=%1 results=%2 is_ok=%3 list=%4', |
|
|
|
dns_name, results, is_ok, rule.backend.config.list) |
|
|
|
|
|
|
|
-- Now split tokens to list of values |
|
|
|
if is_ok then |
|
|
|
local values = {} |
|
|
|
-- Format: key1=num1;key2=num2...keyn=numn |
|
|
|
fun.each(function(e) |
|
|
|
local vals = lua_util.rspamd_str_split(e, "=") |
|
|
|
if vals and #vals == 2 then |
|
|
|
local nv = tonumber(vals[2]) |
|
|
|
if nv then |
|
|
|
values[vals[1]] = nv |
|
|
|
end |
|
|
|
end |
|
|
|
end, |
|
|
|
lua_util.rspamd_str_split(results[1], ";")) |
|
|
|
|
|
|
|
continuation_cb(nil, dns_name, values) |
|
|
|
else |
|
|
|
continuation_cb(results, dns_name, nil) |
|
|
|
end |
|
|
|
|
|
|
|
task:inc_dns_req() |
|
|
|
end |
|
|
|
|
|
|
|
local function reputation_redis_init(rule, cfg, ev_base, worker) |