From a8d5fe6d9d7ef8525db22577113051efb97a53e5 Mon Sep 17 00:00:00 2001 From: Andrew Lewis Date: Wed, 10 Aug 2016 16:50:17 +0200 Subject: [PATCH] [Feature] Simple mechanism for disabling RBLs in local.d/rbl.conf --- src/plugins/lua/rbl.lua | 145 ++++++++++++++++++++-------------------- 1 file changed, 74 insertions(+), 71 deletions(-) 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 -- 2.39.5