Skip to content

Commit

Permalink
[Fix] Prefer surbl/emails rule on rbl to preserve compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
vstakhov committed Sep 12, 2019
1 parent 394d0dc commit 7ead4ca
Showing 1 changed file with 59 additions and 59 deletions.
118 changes: 59 additions & 59 deletions lualib/lua_cfg_transform.lua
Expand Up @@ -238,43 +238,43 @@ 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
if rbl_section[name] then
logger.warnx(rspamd_config, 'conflicting names in surbl and rbl rules: %s, ignore rbl rule!',
name)
rbl_section[name] = {}
end
local converted = {
urls = true,
ignore_defaults = true,
}

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 wl then
converted.whitelist = wl
end

if k == 'dkim' and v then
converted.dkim_domainonly = false
converted.dkim_match_from = true
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 == 'emails' and v then
-- To match surbl behaviour
converted.emails_domainonly = true
end
if k == 'dkim' and v then
converted.dkim_domainonly = false
converted.dkim_match_from = true
end

converted[k] = lua_util.deepcopy(v)
if k == 'emails' and v then
-- To match surbl behaviour
converted.emails_domainonly = true
end
rbl_section[name] = converted
else
logger.warnx(rspamd_config, 'conflicting names in surbl and rbl rules: %s, ignore surbl rule',
name)

converted[k] = lua_util.deepcopy(v)
end
rbl_section[name] = converted
end
end

Expand All @@ -283,39 +283,39 @@ 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 rbl_section[name] then
logger.warnx(rspamd_config, 'conflicting names in emails and rbl rules: %s, ignore rbl rule!',
name)
rbl_section[name] = {}
end
local converted = {
emails = true,
ignore_defaults = true,
}

if wl then
converted.whitelist = wl
end
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
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

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)

converted[k] = lua_util.deepcopy(v)
end
rbl_section[name] = converted
end
end

Expand Down

0 comments on commit 7ead4ca

Please sign in to comment.