aboutsummaryrefslogtreecommitdiffstats
path: root/lualib
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-09-02 16:20:40 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-09-02 16:20:40 +0100
commit671c60076f1e0b1b9af9ae76f144e7145d16d7e5 (patch)
tree51c5a79cac52c0a6d9e9f03a62b40eee004c5c23 /lualib
parent591180aeaf924cea77975dee023991d478849fe5 (diff)
downloadrspamd-671c60076f1e0b1b9af9ae76f144e7145d16d7e5.tar.gz
rspamd-671c60076f1e0b1b9af9ae76f144e7145d16d7e5.zip
[Rework] Convert emails rules to rbl rules
Diffstat (limited to 'lualib')
-rw-r--r--lualib/lua_cfg_transform.lua55
1 files changed, 55 insertions, 0 deletions
diff --git a/lualib/lua_cfg_transform.lua b/lualib/lua_cfg_transform.lua
index 32e1a2ee3..e17ce12ca 100644
--- a/lualib/lua_cfg_transform.lua
+++ b/lualib/lua_cfg_transform.lua
@@ -278,6 +278,47 @@ local function surbl_section_convert(cfg, section)
end
end
+-- Converts surbl module config to rbl module
+local function emails_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 = {
+ emails = true,
+ ignore_defaults = true,
+ }
+
+ if wl then
+ converted.whitelist = wl
+ end
+
+ for k,v in pairs(value) do
+ -- Rename
+ if k == 'dnsbl' then k = 'rbl' end
+ if k == 'check_replyto' then k = 'replyto' end
+ if k == 'hashlen' then k = 'hash_len' end
+ if k == 'encoding' then k = 'hash_format' end
+ if k == 'domain_only' then k = 'emails_domainonly' end
+ if k == 'delimiter' then k = 'emails_delimiter' end
+ if k == 'skip_body' then
+ if v then
+ -- Hack
+ converted.emails = false
+ converted.replyto = true
+ end
+ end
+
+ converted[k] = lua_util.deepcopy(v)
+ end
+ rbl_section[name] = converted
+ else
+ logger.warnx(rspamd_config, 'conflicting names in emails and rbl rules: %s, ignore emails rule',
+ name)
+ end
+ end
+end
+
return function(cfg)
local ret = false
@@ -461,5 +502,19 @@ return function(cfg)
cfg.surbl = {}
end
+ if cfg.emails then
+ if not cfg.rbl then
+ cfg.rbl = {
+ rbls = {}
+ }
+ end
+ if not cfg.rbl.rbls then
+ cfg.rbl.rbls = {}
+ end
+ emails_section_convert(cfg, cfg.emails)
+ logger.infox(rspamd_config, 'converted emails rules to rbl rules')
+ cfg.emails = {}
+ end
+
return ret, cfg
end