redis_key, tostring(options['expire'])
})
else
- rspamd_logger.infox(task, 'got error while connecting to redis: %1', addr)
+ rspamd_logger.infox(task, 'got error while connecting to redis: %1', upstream:get_addr())
upstream:fail()
end
end
local dmarc_domain
local ip_addr = task:get_ip()
- if ((not check_user and task:get_user()) or
+ if ((not check_authed and task:get_user()) or
(not check_local and ip_addr and ip_addr:is_local())) then
rspamd_logger.infox(task, "skip DMARC checks for local networks and authorized users");
return
return maybe_force_action('na')
end
+ local pct
local reason = {}
local strict_spf = false
local strict_dkim = false
end
end
- local pct = elts['pct']
+ pct = elts['pct']
if pct then
pct = tonumber(pct)
end
end
end
- local ret
+ local ret, _
ret,_,upstream = rspamd_redis_make_request(task,
redis_params, -- connect params
hash_key, -- hash key
meta_key, tostring(settings['expire'])
})
else
- rspamd_logger.infox(task, 'got error while connecting to redis: %1', addr)
+ rspamd_logger.infox(task, 'got error while connecting to redis: %1', upstream:get_addr())
upstream:fail()
end
elseif do_greylisting or do_greylisting_required then
return false
end
for _, v in ipairs(settings['metrics']) do
- isvalid = false
+ local isvalid = false
for _, vm in ipairs(valid_metrics) do
if vm == v then
isvalid = true
end
local metrics_str = ''
for _, v in ipairs(settings['metrics']) do
+ local mvalue
local mname = string.format('%s.%s', settings['metric_prefix'], v:gsub(' ', '_'))
local split = rspamd_str_split(v, '.')
if #split == 1 then
end
end)
-- Push metrics to backend
- function push_metrics(worker, time)
+ local function push_metrics(worker, time)
logger.infox('Pushing metrics to %s backend', settings['backend'])
local args = {
ev_base = ev_base,
end
backends[settings['backend']]['push'](args)
end
+ -- Push metrics at regular intervals
+ local function schedule_regular_push()
+ rspamd_config:add_periodic(ev_base, settings['interval'], function (cfg, ev_base)
+ push_metrics(worker)
+ return true
+ end)
+ end
-- Push metrics to backend and reschedule check
- function schedule_intermediate_push(when)
+ local function schedule_intermediate_push(when)
rspamd_config:add_periodic(ev_base, when, function (cfg, ev_base)
push_metrics(worker)
schedule_regular_push()
return false
end)
end
- -- Push metrics at regular intervals
- function schedule_regular_push()
- rspamd_config:add_periodic(ev_base, settings['interval'], function (cfg, ev_base)
- push_metrics(worker)
- return true
- end)
- end
-- Try read statefile on startup
local stamp
local f, err = io.open(settings['statefile'], 'r')
if not r['re_filter'] then
rspamd_logger.errx(task, 'bad search filter: %s', filter)
else
- local results = r['re_filter']:search(fn)
+ local results = r['re_filter']:search(fn, false, true)
if results then
- return results[1]
+ return results[1][2]
else
return nil
end
header = apply_addr_filter,
url = apply_url_filter,
filename = apply_filename_filter,
- mempool = apply_regex_filter,
+ mempool = apply_regexp_filter,
--content = apply_content_filter, -- Content filters are special :(
}
local found_path = false
local found_query = false
local data = nil
+ local d
if elt then
local path = url:get_path()
end
end
-local function phishing_map(mapname, phishmap)
+local function phishing_map(mapname, phishmap, id)
if opts[mapname] then
local xd = {}
if type(opts[mapname]) == 'table' then
end
if opts then
+ local id
if opts['symbol'] then
symbol = opts['symbol']
-- Register symbol's callback
- local id = rspamd_config:register_symbol({
+ id = rspamd_config:register_symbol({
name = symbol,
callback = phishing_cb
})
name = phishtank_symbol,
})
end
- if opts['domains'] and type(opt['domains']) == 'string' then
+ if opts['domains'] and type(opts['domains']) == 'string' then
domains = rspamd_config:add_map({
url = opts['domains'],
type = 'set',
description = 'Phishing domains'
})
end
- phishing_map('strict_domains', strict_domains)
- phishing_map('redirector_domains', redirector_domains)
+ phishing_map('strict_domains', strict_domains, id)
+ phishing_map('redirector_domains', redirector_domains, id)
end
end
for _,result in pairs(results) do
local ipstr = result:to_string()
- local foundrc
+ local foundrc, s
for s,i in pairs(rbl['returncodes']) do
if type(i) == 'string' then
if string.find(ipstr, '^' .. i .. '$') then
-- Plugin defaults should not be changed - override these in config
-- New defaults should not alter behaviour
-default_defaults = {
+local default_defaults = {
['default_ipv4'] = {[1] = true, [2] = 'ipv4'},
['default_ipv6'] = {[1] = false, [2] = 'ipv6'},
['default_received'] = {[1] = true, [2] = 'received'},
for key,rbl in pairs(opts['rbls']) do
(function()
if rbl['disabled'] then return end
+ local s
for default, default_v in pairs(default_defaults) do
if(rbl[default_v[2]] == nil) then
rbl[default_v[2]] = opts[default]
end
for _, w in pairs(white_symbols) do
for _, b in pairs(black_symbols) do
- csymbol = 'RBL_COMPOSITE_' .. w .. '_' .. b
+ local csymbol = 'RBL_COMPOSITE_' .. w .. '_' .. b
rspamd_config:set_metric_symbol(csymbol, 0, 'Autogenerated composite')
rspamd_config:add_composite(csymbol, w .. ' & ' .. b)
end
type = "mempool";
variable = "asn";
map = "redis://asn";
- filter = "regexp:/^(\d).*/";
+ filter = "regexp:/^([0-9]).*/";
}
}