From 882ee5fee6581ba5c673d50a43ab897196cb9ed0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= Date: Sun, 15 Jul 2018 12:01:28 +0200 Subject: [PATCH] [Rspamd] Re-use fixed new ratelimit --- data/conf/rspamd/lua/ratelimit.lua | 27 +++++++++------------------ data/conf/rspamd/lua/rspamd.local.lua | 4 ++-- 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/data/conf/rspamd/lua/ratelimit.lua b/data/conf/rspamd/lua/ratelimit.lua index a7beac49..635fe3e8 100644 --- a/data/conf/rspamd/lua/ratelimit.lua +++ b/data/conf/rspamd/lua/ratelimit.lua @@ -1,25 +1,16 @@ -local custom_keywords = { - ['customrl'] = {}, -} +local custom_keywords = {} -function custom_keywords.customrl.get_value(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) +custom_keywords.mailcow = function(task) local rspamd_logger = require "rspamd_logger" local dyn_rl_symbol = task:get_symbol("DYN_RL") if dyn_rl_symbol then local rl_value = dyn_rl_symbol[1].options[1] - rspamd_logger.infox(rspamd_config, "dynamic ratelimit symbol has option %s, returning...", rl_value) - return rl_value + local rl_object = dyn_rl_symbol[1].options[2] + 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 --- returning custom keywords -return custom_keywords \ No newline at end of file + +return custom_keywords diff --git a/data/conf/rspamd/lua/rspamd.local.lua b/data/conf/rspamd/lua/rspamd.local.lua index 64a2fbc4..7c9efbb4 100644 --- a/data/conf/rspamd/lua/rspamd.local.lua +++ b/data/conf/rspamd/lua/rspamd.local.lua @@ -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) else 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 @@ -94,7 +94,7 @@ rspamd_config:register_symbol({ end else 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