- Also fix some bugs along the waytags/1.4.0
@@ -86,7 +86,7 @@ local function asn_check(task) | |||
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 |
@@ -96,7 +96,7 @@ local function dmarc_callback(task) | |||
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 | |||
@@ -145,6 +145,7 @@ local function dmarc_callback(task) | |||
return maybe_force_action('na') | |||
end | |||
local pct | |||
local reason = {} | |||
local strict_spf = false | |||
local strict_dkim = false | |||
@@ -221,7 +222,7 @@ local function dmarc_callback(task) | |||
end | |||
end | |||
local pct = elts['pct'] | |||
pct = elts['pct'] | |||
if pct then | |||
pct = tonumber(pct) | |||
end |
@@ -226,7 +226,7 @@ local function greylist_check(task) | |||
end | |||
end | |||
local ret | |||
local ret, _ | |||
ret,_,upstream = rspamd_redis_make_request(task, | |||
redis_params, -- connect params | |||
hash_key, -- hash key | |||
@@ -312,7 +312,7 @@ local function greylist_set(task) | |||
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 |
@@ -66,7 +66,7 @@ local function graphite_config(opts) | |||
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 | |||
@@ -95,6 +95,7 @@ local function graphite_push(kwargs) | |||
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 | |||
@@ -171,7 +172,7 @@ rspamd_config:add_on_load(function (cfg, ev_base, worker) | |||
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, | |||
@@ -182,21 +183,21 @@ rspamd_config:add_on_load(function (cfg, ev_base, worker) | |||
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') |
@@ -255,9 +255,9 @@ local function apply_regexp_filter(task, filter, fn, 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 | |||
@@ -305,7 +305,7 @@ local multimap_filters = { | |||
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 :( | |||
} | |||
@@ -49,6 +49,7 @@ local function phishing_cb(task) | |||
local found_path = false | |||
local found_query = false | |||
local data = nil | |||
local d | |||
if elt then | |||
local path = url:get_path() | |||
@@ -168,7 +169,7 @@ local function phishing_cb(task) | |||
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 | |||
@@ -331,10 +332,11 @@ local function phishtank_json_cb(string) | |||
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 | |||
}) | |||
@@ -396,13 +398,13 @@ if opts then | |||
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 |
@@ -72,7 +72,7 @@ local function rbl_cb (task) | |||
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 | |||
@@ -392,7 +392,7 @@ end | |||
-- 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'}, | |||
@@ -433,6 +433,7 @@ local id = rspamd_config:register_symbol({ | |||
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] | |||
@@ -526,7 +527,7 @@ for key,rbl in pairs(opts['rbls']) do | |||
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 |
@@ -110,6 +110,6 @@ multimap { | |||
type = "mempool"; | |||
variable = "asn"; | |||
map = "redis://asn"; | |||
filter = "regexp:/^(\d).*/"; | |||
filter = "regexp:/^([0-9]).*/"; | |||
} | |||
} |