diff options
author | korgoth1 <vladislav.stakhov@gmail.com> | 2020-01-15 23:35:46 +0300 |
---|---|---|
committer | korgoth1 <vladislav.stakhov@gmail.com> | 2020-01-15 23:35:46 +0300 |
commit | a134799dddb07dca45196ccc9737415d2cc5b586 (patch) | |
tree | 52dbd0d74e43f0216a3cfe7a2414307180939df9 /src/plugins | |
parent | 092fa9c14831bc0460bd25190fa013697f572354 (diff) | |
download | rspamd-a134799dddb07dca45196ccc9737415d2cc5b586.tar.gz rspamd-a134799dddb07dca45196ccc9737415d2cc5b586.zip |
[Test] SPF external IP map
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/lua/spf.lua | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/plugins/lua/spf.lua b/src/plugins/lua/spf.lua index 10daa0d2b..3dbef56a5 100644 --- a/src/plugins/lua/spf.lua +++ b/src/plugins/lua/spf.lua @@ -67,6 +67,7 @@ local default_config = { disable_ipv6 = false, symbols = symbols, external_relay = nil, + external_map = nil, } local local_config = rspamd_config:get_all_opt('spf') @@ -89,7 +90,8 @@ 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 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] @@ -218,7 +220,7 @@ if local_config.whitelist then "radix", "SPF whitelist map") end -if local_config.external_relay then +--[[if local_config.external_relay then local rspamd_ip = require "rspamd_ip" local ip = rspamd_ip.from_string(local_config.external_relay) @@ -228,9 +230,29 @@ if local_config.external_relay then 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') +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, |