[Rspamd] Re-use fixed new ratelimit
parent
853b924fe1
commit
882ee5fee6
|
@ -1,25 +1,16 @@
|
||||||
local custom_keywords = {
|
local custom_keywords = {}
|
||||||
['customrl'] = {},
|
|
||||||
}
|
|
||||||
|
|
||||||
function custom_keywords.customrl.get_value(task)
|
custom_keywords.mailcow = function(task)
|
||||||
local rspamd_logger = require "rspamd_logger"
|
|
||||||
if task:has_symbol('DYN_RL') then
|
|
||||||
rspamd_logger.infox(rspamd_config, "task has a dynamic ratelimit symbol, processing...")
|
|
||||||
return "check"
|
|
||||||
else
|
|
||||||
rspamd_logger.infox(rspamd_config, "task has no dynamic ratelimit symbol, skipping...")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
function custom_keywords.customrl.get_limit(task)
|
|
||||||
local rspamd_logger = require "rspamd_logger"
|
local rspamd_logger = require "rspamd_logger"
|
||||||
local dyn_rl_symbol = task:get_symbol("DYN_RL")
|
local dyn_rl_symbol = task:get_symbol("DYN_RL")
|
||||||
if dyn_rl_symbol then
|
if dyn_rl_symbol then
|
||||||
local rl_value = dyn_rl_symbol[1].options[1]
|
local rl_value = dyn_rl_symbol[1].options[1]
|
||||||
rspamd_logger.infox(rspamd_config, "dynamic ratelimit symbol has option %s, returning...", rl_value)
|
local rl_object = dyn_rl_symbol[1].options[2]
|
||||||
return rl_value
|
if rl_value and rl_object then
|
||||||
|
rspamd_logger.infox(rspamd_config, "DYN_RL symbol has value %s for object %s, returning %s...", rl_value, rl_object, "rs_dynrl_" .. rl_object)
|
||||||
|
return "rs_dynrl_" .. rl_object, rl_value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- returning custom keywords
|
end
|
||||||
|
|
||||||
return custom_keywords
|
return custom_keywords
|
|
@ -77,7 +77,7 @@ rspamd_config:register_symbol({
|
||||||
rspamd_logger.infox(rspamd_config, "dynamic ratelimit request for domain %s returned invalid or empty data (\"%s\") or error (\"%s\")", env_from_domain, data, err)
|
rspamd_logger.infox(rspamd_config, "dynamic ratelimit request for domain %s returned invalid or empty data (\"%s\") or error (\"%s\")", env_from_domain, data, err)
|
||||||
else
|
else
|
||||||
rspamd_logger.infox(rspamd_config, "found dynamic ratelimit in redis for domain %s with value %s", env_from_domain, data)
|
rspamd_logger.infox(rspamd_config, "found dynamic ratelimit in redis for domain %s with value %s", env_from_domain, data)
|
||||||
task:insert_result('DYN_RL', 0.0, data)
|
task:insert_result('DYN_RL', 0.0, data, env_from_domain)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ rspamd_config:register_symbol({
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
rspamd_logger.infox(rspamd_config, "found dynamic ratelimit in redis for user %s with value %s", uname, data)
|
rspamd_logger.infox(rspamd_config, "found dynamic ratelimit in redis for user %s with value %s", uname, data)
|
||||||
task:insert_result('DYN_RL', 0.0, data)
|
task:insert_result('DYN_RL', 0.0, data, uname)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue