Browse Source

Merge pull request #3215 from korgoth1/master

[Feature] SPF: Convert external IP to a map
pull/3225/head
Vsevolod Stakhov 6 years ago
committed by GitHub
parent
commit
dae6f5e3d3
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      conf/maps.d/surbl-whitelist.inc
  2. 7
      conf/modules.d/spf.conf
  3. 14
      src/plugins/lua/spf.lua
  4. 4
      test/functional/configs/dmarc.conf
  5. 1
      test/functional/configs/maps/external_relay_ip.list

2
conf/maps.d/surbl-whitelist.inc

@ -827,4 +827,4 @@ lists.isc.org
lists.roundcube.net
svn.apache.org
taggedmail.com
tumblr.com
tumblr.com

7
conf/modules.d/spf.conf

@ -15,7 +15,14 @@ spf {
spf_cache_size = 2k;
spf_cache_expire = 1d;
#external_relay = [
#"$LOCAL_CONFDIR/local.d/maps.d/external_relay_ip.inc.local",
#"${DBDIR}/surbl-external_relay_ip.inc.local",
#"fallback+file://${CONFDIR}/maps.d/external_relay_ip.inc"
#];
.include(try=true,priority=5) "${DBDIR}/dynamic/spf.conf"
.include(try=true,priority=1,duplicate=merge) "$LOCAL_CONFDIR/local.d/spf.conf"
.include(try=true,priority=10) "$LOCAL_CONFDIR/override.d/spf.conf"
}

14
src/plugins/lua/spf.lua

@ -89,7 +89,7 @@ local function spf_check_callback(task)
local found = false
for i,hdr in ipairs(rh) do
if hdr.real_ip and hdr.real_ip == local_config.external_relay then
if hdr.real_ip and local_config.external_relay:get_key(hdr.real_ip) then
-- We can use the next header as a source of IP address
if rh[i + 1] then
local nhdr = rh[i + 1]
@ -219,16 +219,10 @@ if local_config.whitelist then
end
if local_config.external_relay then
local rspamd_ip = require "rspamd_ip"
local ip = rspamd_ip.from_string(local_config.external_relay)
local lua_maps = require "lua_maps"
if not ip or not ip:is_valid() then
rspamd_logger.errx(rspamd_config, "invalid external relay IP: %s",
local_config.external_relay)
local_config.external_relay = nil
else
local_config.external_relay = ip
end
local_config.external_relay = lua_maps.map_add_from_ucl(local_config.external_relay,
"radix", "External IP SPF map")
end
for _,sym in pairs(local_config.symbols) do

4
test/functional/configs/dmarc.conf

@ -1,4 +1,6 @@
dmarc { }
spf {
external_relay = 192.168.1.1;
external_relay = [
"${TESTDIR}/configs/maps/external_relay_ip.list",
];
}

1
test/functional/configs/maps/external_relay_ip.list

@ -0,0 +1 @@
192.168.1.1
Loading…
Cancel
Save