-- https://rspamd.com/doc/modules/rbl.html
local rbls = {}
+local local_exclusions = nil
local rspamd_logger = require "rspamd_logger"
local rspamd_ip = require "rspamd_ip"
return false
end
+local function is_excluded_ip(rip)
+ if local_exclusions and local_exclusions:get_key(rip) then
+ return true
+ end
+ return false
+end
+
local function ip_to_rbl(ip, rbl)
return table.concat(ip:inversed_str_octets(), ".") .. '.' .. rbl
end
if not havegot['from'] then
havegot['from'] = task:get_from_ip()
if not havegot['from']:is_valid() or
- (rbl['exclude_private_ips'] and is_private_ip(havegot['from'])) then
+ (rbl['exclude_private_ips'] and is_private_ip(havegot['from']))
+ or is_excluded_ip(havegot['from']) then
notgot['from'] = true
return
end
if ((rh['real_ip']:get_version() == 6 and rbl['ipv6']) or
(rh['real_ip']:get_version() == 4 and rbl['ipv4'])) and
((rbl['exclude_private_ips'] and not is_private_ip(rh['real_ip'])) or
- not rbl['exclude_private_ips']) then
+ not rbl['exclude_private_ips']) and not is_excluded_ip(rh['real_ip']) then
task:get_resolver():resolve_a(task:get_session(), task:get_mempool(),
ip_to_rbl(rh['real_ip'], rbl['rbl']), rbl_dns_cb, k)
end
rspamd_config:register_module_option('rbl', 'default_unknown', 'string')
rspamd_config:register_module_option('rbl', 'default_exclude_users', 'string')
rspamd_config:register_module_option('rbl', 'default_exclude_private_ips', 'string')
+ rspamd_config:register_module_option('rbl', 'local_exclude_ip_map', 'string')
end
end
opts['default_exclude_private_ips'] = false
end
+if(opts['local_exclude_ip_map'] ~= nil) then
+ local_exclusions = rspamd_config:add_radix_map(opts['local_exclude_ip_map'])
+end
+
for key,rbl in pairs(opts['rbls']) do
local o = { "ipv4", "ipv6", "from", "received", "unknown", "rdns", "helo", "exclude_users", "exclude_private_ips" }
for i=1,table.maxn(o) do