diff options
Diffstat (limited to 'src/plugins/lua/rbl.lua')
-rw-r--r-- | src/plugins/lua/rbl.lua | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/plugins/lua/rbl.lua b/src/plugins/lua/rbl.lua index ce43e54a2..1651d626b 100644 --- a/src/plugins/lua/rbl.lua +++ b/src/plugins/lua/rbl.lua @@ -297,6 +297,8 @@ if type(rspamd_config.get_api_version) ~= 'nil' then rspamd_config:register_module_option('rbl', 'default_exclude_local', 'string') rspamd_config:register_module_option('rbl', 'private_ips', 'string') rspamd_config:register_module_option('rbl', 'default_emails', 'string') + rspamd_config:register_module_option('rbl', 'default_is_whitelist', 'string') + rspamd_config:register_module_option('rbl', 'default_ignore_whitelists', 'string') end end @@ -321,6 +323,8 @@ default_defaults = { ['default_exclude_private_ips'] = {[1] = true, [2] = 'exclude_private_ips'}, ['default_exclude_users'] = {[1] = false, [2] = 'exclude_users'}, ['default_exclude_local'] = {[1] = true, [2] = 'exclude_local'}, + ['default_is_whitelist'] = {[1] = false, [2] = 'is_whitelist'}, + ['default_ignore_whitelist'] = {[1] = false, [2] = 'ignore_whitelists'}, } for default, default_v in pairs(default_defaults) do if opts[default] == nil then @@ -335,6 +339,9 @@ if(opts['private_ips'] ~= nil) then private_ips = rspamd_config:radix_from_config('rbl', 'private_ips') end +local white_symbols = {} +local black_symbols = {} + for key,rbl in pairs(opts['rbls']) do for default, default_v in pairs(default_defaults) do if(rbl[default_v[2]] == nil) then @@ -345,6 +352,11 @@ for key,rbl in pairs(opts['rbls']) do for s,_ in pairs(rbl['returncodes']) do if type(rspamd_config.get_api_version) ~= 'nil' then rspamd_config:register_virtual_symbol(s, 1) + if(rbl['is_whitelist']) then + table.insert(white_symbols, s) + else + table.insert(black_symbols, s) + end end end end @@ -353,7 +365,22 @@ for key,rbl in pairs(opts['rbls']) do end if type(rspamd_config.get_api_version) ~= 'nil' and rbl['symbol'] then rspamd_config:register_virtual_symbol(rbl['symbol'], 1) + if(rbl['is_whitelist']) then + table.insert(white_symbols, rbl['symbol']) + else + if rbl['ignore_whitelists'] == false then + table.insert(black_symbols, rbl['symbol']) + end + end end rbls[key] = rbl end +for _, w in pairs(white_symbols) do + for _, b in pairs(black_symbols) do + csymbol = 'RBL_COMPOSITE_' .. w .. '_' .. b + rspamd_config:register_virtual_symbol(csymbol, 1) + rspamd_config:add_composite(csymbol, w .. ' & ' .. b) + rspamd_config:set_metric_symbol(csymbol, 0, 'Autogenerated composite') + end +end rspamd_config:register_callback_symbol_priority('RBL', 1.0, 0, rbl_cb) |