From: Andrew Lewis Date: Wed, 10 Aug 2016 14:50:17 +0000 (+0200) Subject: [Feature] Simple mechanism for disabling RBLs in local.d/rbl.conf X-Git-Tag: 1.3.3~36^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Fpull%2F834%2Fhead;p=rspamd.git [Feature] Simple mechanism for disabling RBLs in local.d/rbl.conf --- diff --git a/src/plugins/lua/rbl.lua b/src/plugins/lua/rbl.lua index 2a0042019..0ccfa4405 100644 --- a/src/plugins/lua/rbl.lua +++ b/src/plugins/lua/rbl.lua @@ -379,91 +379,94 @@ local id = rspamd_config:register_symbol({ }) for key,rbl in pairs(opts['rbls']) do - for default, default_v in pairs(default_defaults) do - if(rbl[default_v[2]] == nil) then - rbl[default_v[2]] = opts[default] + (function() + if rbl['disabled'] then return end + for default, default_v in pairs(default_defaults) do + if(rbl[default_v[2]] == nil) then + rbl[default_v[2]] = opts[default] + end end - end - if type(rbl['returncodes']) == 'table' then - for s,_ in pairs(rbl['returncodes']) do - if type(rspamd_config.get_api_version) ~= 'nil' then - rspamd_config:register_symbol({ - name = s, - parent = id, - type = 'virtual' - }) - - if rbl['dkim'] then - need_dkim = true - end - if(rbl['is_whitelist']) then - if type(rbl['whitelist_exception']) == 'string' then - if (rbl['whitelist_exception'] ~= s) then - table.insert(white_symbols, s) - end - elseif type(rbl['whitelist_exception']) == 'table' then - local foundException = false - for _, e in pairs(rbl['whitelist_exception']) do - if e == s then - foundException = true - break + if type(rbl['returncodes']) == 'table' then + for s,_ in pairs(rbl['returncodes']) do + if type(rspamd_config.get_api_version) ~= 'nil' then + rspamd_config:register_symbol({ + name = s, + parent = id, + type = 'virtual' + }) + + if rbl['dkim'] then + need_dkim = true + end + if(rbl['is_whitelist']) then + if type(rbl['whitelist_exception']) == 'string' then + if (rbl['whitelist_exception'] ~= s) then + table.insert(white_symbols, s) end - end - if not foundException then - table.insert(white_symbols, s) + elseif type(rbl['whitelist_exception']) == 'table' then + local foundException = false + for _, e in pairs(rbl['whitelist_exception']) do + if e == s then + foundException = true + break + end + end + if not foundException then + table.insert(white_symbols, s) + end + else + table.insert(white_symbols, s) end else - table.insert(white_symbols, s) - end - else - if rbl['ignore_whitelists'] == false then - table.insert(black_symbols, s) + if rbl['ignore_whitelists'] == false then + table.insert(black_symbols, s) + end end end end end - end - if not rbl['symbol'] and - ((rbl['returncodes'] and rbl['unknown']) or - (not rbl['returncodes'])) then - rbl['symbol'] = key - end - if type(rspamd_config.get_api_version) ~= 'nil' and rbl['symbol'] then - rspamd_config:register_symbol({ - name = rbl['symbol'], - parent = id, - type = 'virtual' - }) - - if rbl['dkim'] then - need_dkim = true + if not rbl['symbol'] and + ((rbl['returncodes'] and rbl['unknown']) or + (not rbl['returncodes'])) then + rbl['symbol'] = key end - if(rbl['is_whitelist']) then - if type(rbl['whitelist_exception']) == 'string' then - if (rbl['whitelist_exception'] ~= rbl['symbol']) then - table.insert(white_symbols, rbl['symbol']) - end - elseif type(rbl['whitelist_exception']) == 'table' then - local foundException = false - for _, e in pairs(rbl['whitelist_exception']) do - if e == s then - foundException = true - break + if type(rspamd_config.get_api_version) ~= 'nil' and rbl['symbol'] then + rspamd_config:register_symbol({ + name = rbl['symbol'], + parent = id, + type = 'virtual' + }) + + if rbl['dkim'] then + need_dkim = true + end + if(rbl['is_whitelist']) then + if type(rbl['whitelist_exception']) == 'string' then + if (rbl['whitelist_exception'] ~= rbl['symbol']) then + table.insert(white_symbols, rbl['symbol']) end - end - if not foundException then + elseif type(rbl['whitelist_exception']) == 'table' then + local foundException = false + for _, e in pairs(rbl['whitelist_exception']) do + if e == s then + foundException = true + break + end + end + if not foundException then + table.insert(white_symbols, rbl['symbol']) + end + else table.insert(white_symbols, rbl['symbol']) end - else - table.insert(white_symbols, rbl['symbol']) - end - else - if rbl['ignore_whitelists'] == false then - table.insert(black_symbols, rbl['symbol']) + else + if rbl['ignore_whitelists'] == false then + table.insert(black_symbols, rbl['symbol']) + end end end - end - rbls[key] = rbl + rbls[key] = rbl + end)() end for _, w in pairs(white_symbols) do for _, b in pairs(black_symbols) do