diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-08-27 18:42:51 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-08-27 18:42:51 +0100 |
commit | 259c79b98d420286271b3f02901771feb3a4a081 (patch) | |
tree | e2bcc330d5a3baf111a6bb15cb28db25accdacd6 /lualib/lua_cfg_transform.lua | |
parent | 97d6e1e7197ee4b804a09a164c81a1a9e68e7910 (diff) | |
download | rspamd-259c79b98d420286271b3f02901771feb3a4a081.tar.gz rspamd-259c79b98d420286271b3f02901771feb3a4a081.zip |
[Rework] Convert surbl rules to rbl rules
Diffstat (limited to 'lualib/lua_cfg_transform.lua')
-rw-r--r-- | lualib/lua_cfg_transform.lua | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/lualib/lua_cfg_transform.lua b/lualib/lua_cfg_transform.lua index f74d6d49d..07a53723e 100644 --- a/lualib/lua_cfg_transform.lua +++ b/lualib/lua_cfg_transform.lua @@ -233,6 +233,46 @@ local function check_statistics_sanity() end end +-- Converts surbl module config to rbl module +local function surbl_section_convert(cfg, section) + local rbl_section = cfg.rbl.rbls + local wl = section.whitelist + for name,value in pairs(section.rules or {}) do + if not rbl_section[name] then + local converted = { + urls = true, + ignore_defaults = true, + } + + if wl then + converted.whitelist = wl + end + + for k,v in pairs(value) do + -- Rename + if k == 'suffix' then k = 'rbl' end + if k == 'ips' then k = 'returncodes' end + if k == 'bits' then k = 'returnbits' end + if k:match('check_') then + local n = k:match('check_(.*)') + k = n + end + + if k == 'dkim' and v then + converted.dkim_domainonly = false + converted.dkim_match_from = true + end + + converted[k] = lua_util.deepcopy(v) + end + rbl_section[name] = converted + else + logger.warnx(rspamd_config, 'conflicting names in surbl and rbl rules: %s, ignore surbl rule', + name) + end + end +end + return function(cfg) local ret = false @@ -402,5 +442,19 @@ return function(cfg) end end + if cfg.surbl then + if not cfg.rbl then + cfg.rbl = { + rbls = {} + } + end + if not cfg.rbl.rbls then + cfg.rbl.rbls = {} + end + surbl_section_convert(cfg, cfg.surbl) + logger.infox(rspamd_config, 'converted surbl rules to rbl rules') + cfg.surbl = {} + end + return ret, cfg end |