Browse Source

[Minor] Slightly improve logging

tags/1.7.6
Vsevolod Stakhov 6 years ago
parent
commit
4653f1e903
2 changed files with 6 additions and 5 deletions
  1. 5
    4
      src/plugins/lua/asn.lua
  2. 1
    1
      src/plugins/lua/emails.lua

+ 5
- 4
src/plugins/lua/asn.lua View File



local asn_check_func = {} local asn_check_func = {}
function asn_check_func.rspamd(ip) function asn_check_func.rspamd(ip)
local dnsbl = options['provider_info']['ip' .. ip:get_version()]
local req_name = rspamd_logger.slog("%1.%2",
table.concat(ip:inversed_str_octets(), '.'), dnsbl)
local function rspamd_dns_cb(_, _, results, dns_err) local function rspamd_dns_cb(_, _, results, dns_err)
if dns_err and (dns_err ~= 'requested record is not found' and dns_err ~= 'no records with this name') then if dns_err and (dns_err ~= 'requested record is not found' and dns_err ~= 'no records with this name') then
rspamd_logger.errx(task, 'error querying dns: %s', dns_err)
rspamd_logger.errx(task, 'error querying dns (%s): %s', req_name, dns_err)
end end
if not (results and results[1]) then return end if not (results and results[1]) then return end
local parts = rspamd_re:split(results[1]) local parts = rspamd_re:split(results[1])
-- "15169 | 8.8.8.0/24 | US | arin |" for 8.8.8.8 -- "15169 | 8.8.8.0/24 | US | arin |" for 8.8.8.8
asn_set(parts[1], parts[2], parts[3]) asn_set(parts[1], parts[2], parts[3])
end end
local dnsbl = options['provider_info']['ip' .. ip:get_version()]
local req_name = rspamd_logger.slog("%1.%2",
table.concat(ip:inversed_str_octets(), '.'), dnsbl)

task:get_resolver():resolve_txt(task:get_session(), task:get_mempool(), task:get_resolver():resolve_txt(task:get_session(), task:get_mempool(),
req_name, rspamd_dns_cb) req_name, rspamd_dns_cb)
end end

+ 1
- 1
src/plugins/lua/emails.lua View File

local function emails_dns_cb(_, _, results, err) local function emails_dns_cb(_, _, results, err)
if err and (err ~= 'requested record is not found' if err and (err ~= 'requested record is not found'
and err ~= 'no records with this name') then and err ~= 'no records with this name') then
logger.errx(task, 'Error querying DNS: %1', err)
logger.errx(task, 'Error querying DNS(%s): %s', to_resolve, err)
elseif results then elseif results then
local expected_found = false local expected_found = false
local symbol = rule['symbol'] local symbol = rule['symbol']

Loading…
Cancel
Save