This reverts commit c3c8d4d133
.
tags/2.1
if configure_asn_module() then | if configure_asn_module() then | ||||
local id = rspamd_config:register_symbol({ | local id = rspamd_config:register_symbol({ | ||||
name = 'ASN_CHECK', | name = 'ASN_CHECK', | ||||
type = 'prefilter,nostat,empty', | |||||
type = 'prefilter,nostat', | |||||
callback = asn_check, | callback = asn_check, | ||||
priority = 8, | priority = 8, | ||||
flags = 'empty', | |||||
}) | }) | ||||
if options['symbol'] then | if options['symbol'] then | ||||
rspamd_config:register_symbol({ | rspamd_config:register_symbol({ |
['get_value'] = function(task) | ['get_value'] = function(task) | ||||
return task:get_principal_recipient() | return task:get_principal_recipient() | ||||
end, | end, | ||||
need_process = true, | |||||
}, | }, | ||||
['digest'] = { | ['digest'] = { | ||||
['get_value'] = function(task) | ['get_value'] = function(task) | ||||
return task:get_digest() | return task:get_digest() | ||||
end, | end, | ||||
need_process = true, | |||||
}, | }, | ||||
['attachments'] = { | ['attachments'] = { | ||||
['get_value'] = function(task) | ['get_value'] = function(task) | ||||
return nil | return nil | ||||
end, | end, | ||||
need_process = true, | |||||
}, | }, | ||||
['files'] = { | ['files'] = { | ||||
['get_value'] = function(task) | ['get_value'] = function(task) | ||||
return nil | return nil | ||||
end, | end, | ||||
need_process = true, | |||||
}, | }, | ||||
} | } | ||||
local key_t = {tostring(lua_util.round(100000.0 / bucket.burst))} | local key_t = {tostring(lua_util.round(100000.0 / bucket.burst))} | ||||
local key_keywords = lua_util.str_split(rtype, '_') | local key_keywords = lua_util.str_split(rtype, '_') | ||||
local have_user = false | local have_user = false | ||||
local message_processed = false | |||||
for _, v in ipairs(key_keywords) do | for _, v in ipairs(key_keywords) do | ||||
local ret | local ret | ||||
if keywords[v] and type(keywords[v]['get_value']) == 'function' then | if keywords[v] and type(keywords[v]['get_value']) == 'function' then | ||||
if keywords[v].need_process and not message_processed then | |||||
lua_util.debugm(N, task, 'process message as %s needs mime elts', | |||||
v) | |||||
message_processed = task:process_message() | |||||
message_processed = true | |||||
end | |||||
ret = keywords[v].get_value(task) | |||||
ret = keywords[v]['get_value'](task) | |||||
end | end | ||||
if not ret then return nil end | if not ret then return nil end | ||||
if v == 'user' then have_user = true end | if v == 'user' then have_user = true end | ||||
local n = 0 | local n = 0 | ||||
for _,bucket in ipairs(v.buckets) do | for _,bucket in ipairs(v.buckets) do | ||||
if v.selector then | if v.selector then | ||||
lua_util.debugm(N, task, 'process message as selectors need mime elts', | |||||
v) | |||||
task:process_message() | |||||
local selectors = lua_selectors.process_selectors(task, v.selector) | local selectors = lua_selectors.process_selectors(task, v.selector) | ||||
if selectors then | if selectors then | ||||
local combined = lua_selectors.combine_selectors(task, selectors, ':') | local combined = lua_selectors.combine_selectors(task, selectors, ':') | ||||
lua_util.disable_module(N, "redis") | lua_util.disable_module(N, "redis") | ||||
else | else | ||||
local s = { | local s = { | ||||
type = 'prefilter,nostat,empty', | |||||
type = 'prefilter,nostat', | |||||
name = 'RATELIMIT_CHECK', | name = 'RATELIMIT_CHECK', | ||||
priority = 7, | priority = 7, | ||||
callback = ratelimit_cb, | callback = ratelimit_cb, | ||||
flags = 'empty', | |||||
} | } | ||||
if settings.symbol then | if settings.symbol then |
-- Check limit for a task | -- Check limit for a task | ||||
local function check_settings(task) | local function check_settings(task) | ||||
local message_processed = false | |||||
local function check_specific_setting(rule, matched) | local function check_specific_setting(rule, matched) | ||||
local res = false | local res = false | ||||
local elt = rule.checks[atom] | local elt = rule.checks[atom] | ||||
if elt then | if elt then | ||||
if elt.need_process and not message_processed then | |||||
lua_util.debugm(N, task, 'process message as %s needs mime elts', | |||||
atom) | |||||
message_processed = task:process_message() | |||||
message_processed = true | |||||
end | |||||
local input = elt.extract(task) | local input = elt.extract(task) | ||||
if not input then return false end | if not input then return false end | ||||
extract = function(task) | extract = function(task) | ||||
return task:get_from(2) | return task:get_from(2) | ||||
end, | end, | ||||
need_process = true, | |||||
} | } | ||||
end | end | ||||
end | end | ||||
extract = function(task) | extract = function(task) | ||||
return task:get_recipients(2) | return task:get_recipients(2) | ||||
end, | end, | ||||
need_process = true, | |||||
} | } | ||||
end | end | ||||
end | end | ||||
return v | return v | ||||
end, | end, | ||||
extract = extractor_func(k), | extract = extractor_func(k), | ||||
need_process = true, | |||||
} | } | ||||
local skey = process_compound_condition(cond, table_element, | local skey = process_compound_condition(cond, table_element, | ||||
end, values) | end, values) | ||||
end, | end, | ||||
extract = sel, | extract = sel, | ||||
need_process = true, | |||||
} | } | ||||
local skey = process_compound_condition(cond, 'selector', elt.selector) | local skey = process_compound_condition(cond, 'selector', elt.selector) | ||||
lua_util.debugm(N, rspamd_config, 'added selector condition to "%s": %s', | lua_util.debugm(N, rspamd_config, 'added selector condition to "%s": %s', |
return | return | ||||
end | end | ||||
local flags | |||||
if not rule['blacklist'] then | |||||
flags = 'nice' | |||||
local flags = 'nice,empty' | |||||
if rule['blacklist'] then | |||||
flags = 'empty' | |||||
end | end | ||||
local id = rspamd_config:register_symbol({ | local id = rspamd_config:register_symbol({ |