aboutsummaryrefslogtreecommitdiffstats
path: root/lualib
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-07-17 17:13:06 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-07-17 17:13:06 +0100
commit48d68b15e08a6c3b597f4de6400815e294c61ace (patch)
tree9e1fc2082667e00d01bfa41cf348cf7a66967629 /lualib
parenta7675359a1f7dffa91430d69c17a0a0a364c8fc2 (diff)
downloadrspamd-48d68b15e08a6c3b597f4de6400815e294c61ace.tar.gz
rspamd-48d68b15e08a6c3b597f4de6400815e294c61ace.zip
[Rework] Migrate from ip_score to reputation
Diffstat (limited to 'lualib')
-rw-r--r--lualib/lua_cfg_transform.lua38
1 files changed, 38 insertions, 0 deletions
diff --git a/lualib/lua_cfg_transform.lua b/lualib/lua_cfg_transform.lua
index 83b979ac5..ac328f86f 100644
--- a/lualib/lua_cfg_transform.lua
+++ b/lualib/lua_cfg_transform.lua
@@ -17,6 +17,7 @@ limitations under the License.
local logger = require "rspamd_logger"
local lua_util = require "lua_util"
local rspamd_util = require "rspamd_util"
+local fun = require "fun"
local function is_implicit(t)
local mt = getmetatable(t)
@@ -358,5 +359,42 @@ return function(cfg)
end
end
+ -- Deal with IP_SCORE
+ if cfg.ip_score then
+ logger.warnx(rspamd_config, 'ip_score module is deprecated in honor of reputation module!')
+
+ if not cfg.reputation then
+ cfg.reputation = {
+ rules = {}
+ }
+ end
+
+ if not fun.any(function(_, v) return v.selector and v.selector.ip end,
+ cfg.reputation.rules) then
+ logger.infox(rspamd_config, 'attach ip reputation element to use it')
+
+ cfg.reputation.rules.ip_score = {
+ selector = {
+ ip = {},
+ },
+ backend = {
+ redis = {},
+ }
+ }
+
+ if cfg.symbols['IP_SCORE'] then
+ local t = cfg.symbols['IP_SCORE']
+
+ if not cfg.symbols['SENDER_REP_SPAM'] then
+ cfg.symbols['SENDER_REP_SPAM'] = t
+ cfg.symbols['SENDER_REP_HAM'] = t
+ cfg.symbols['SENDER_REP_HAM'].weight = -(t.weight or 0)
+ end
+ end
+ else
+ logger.infox(rspamd_config, 'ip reputation already exists, do not do any IP_SCORE transforms')
+ end
+ end
+
return ret, cfg
end