From: Vsevolod Stakhov Date: Tue, 27 Aug 2019 17:42:51 +0000 (+0100) Subject: [Rework] Convert surbl rules to rbl rules X-Git-Tag: 2.0~330 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=259c79b98d420286271b3f02901771feb3a4a081;p=rspamd.git [Rework] Convert surbl rules to rbl rules --- 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