commit 7fde195: [Test] SPF external IP map

korgoth1 vladislav.stakhov at gmail.com
Thu Jan 16 20:07:10 UTC 2020


Author: korgoth1
Date: 2020-01-16 15:06:54 +0300
URL: https://github.com/rspamd/rspamd/commit/7fde19553884b61eccd55a35aef58a3b8ff6a159

[Test] SPF external IP map

---
 src/plugins/lua/spf.lua                            | 30 +---------------------
 test/functional/configs/dmarc.conf                 |  2 +-
 .../functional/configs/maps/external_relay_ip.list |  0
 3 files changed, 2 insertions(+), 30 deletions(-)

diff --git a/src/plugins/lua/spf.lua b/src/plugins/lua/spf.lua
index 3dbef56a5..d6949cd76 100644
--- a/src/plugins/lua/spf.lua
+++ b/src/plugins/lua/spf.lua
@@ -67,7 +67,6 @@ local default_config = {
   disable_ipv6 = false,
   symbols = symbols,
   external_relay = nil,
-  external_map = nil,
 }
 
 local local_config = rspamd_config:get_all_opt('spf')
@@ -90,7 +89,6 @@ 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
@@ -220,39 +218,13 @@ if local_config.whitelist then
       "radix", "SPF whitelist map")
 end
 
---[[if local_config.external_relay then
-  local rspamd_ip = require "rspamd_ip"
-  local ip = rspamd_ip.from_string(local_config.external_relay)
-
-  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 function external_ip_spf(task)
-  if local_config.external_relay then
-    if local_config.external_relay:get_key(task:get_received_headers()) then
-      task:insert_result('EXT_RELAY', 1.0, task:get_received_headers())
-    end
-  end
-end
-
 if local_config.external_relay then
   local lua_maps = require "lua_maps"
 
   local_config.external_relay = lua_maps.map_add_from_ucl(local_config.external_relay,
-    mtype: 'radix', description: 'External IP SPF map')
+   "radix", "External IP SPF map")
 end
 
-rspamd_config:register_symbol{
-  type = 'normal'
-  callback = external_ip_spf,
-  name = 'EXT_RELAY'
-}
-
 for _,sym in pairs(local_config.symbols) do
   rspamd_config:register_symbol{
     name = sym,
diff --git a/test/functional/configs/dmarc.conf b/test/functional/configs/dmarc.conf
index f086f9238..b6164f9d2 100644
--- a/test/functional/configs/dmarc.conf
+++ b/test/functional/configs/dmarc.conf
@@ -1,6 +1,6 @@
 dmarc { }
 spf {
   external_relay = [
-    "$LOCAL_CONFDIR/local.d/maps.d/external_relay_ip.inc.local",
+   	"${TESTDIR}/configs/maps/external_relay_ip.list",
   ];
 }
\ No newline at end of file
diff --git a/conf/maps.d/external_relay_ip.inc b/test/functional/configs/maps/external_relay_ip.list
similarity index 100%
copy from conf/maps.d/external_relay_ip.inc
copy to test/functional/configs/maps/external_relay_ip.list


More information about the Commits mailing list