aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew Lewis <nerf@judo.za.org>2015-09-02 17:33:13 +0200
committerAndrew Lewis <nerf@judo.za.org>2015-09-02 17:48:03 +0200
commitdd6b0d5aabf146c1a09e503f2ac6cf1f6631da32 (patch)
tree50ff70cbd691742026e98f7f9d62658aec4351b1 /src
parent969e64cef11b6b6fe2cdb71c196464b85d3f27f9 (diff)
downloadrspamd-dd6b0d5aabf146c1a09e503f2ac6cf1f6631da32.tar.gz
rspamd-dd6b0d5aabf146c1a09e503f2ac6cf1f6631da32.zip
Allow ip_score to ignore selected ASNs/countries
Diffstat (limited to 'src')
-rw-r--r--src/plugins/lua/ip_score.lua24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/plugins/lua/ip_score.lua b/src/plugins/lua/ip_score.lua
index 8229e342a..171deede7 100644
--- a/src/plugins/lua/ip_score.lua
+++ b/src/plugins/lua/ip_score.lua
@@ -36,6 +36,7 @@ local _ = require "fun"
local default_port = 6379
local upstreams = nil
local whitelist = nil
+local asn_cc_whitelist = nil
local options = {
asn_provider = 'origin.asn.cymru.com', -- provider for ASN data
@@ -152,21 +153,13 @@ local ip_score_set = function(task)
return
end
- -- Check whitelist
- if whitelist then
- if whitelist:get_key(ip) then
- -- Address is whitelisted
- return
- end
- end
-
local pool = task:get_mempool()
local asn, country, ipnet = ip_score_get_task_vars(task)
if not pool:has_variable('ip_score') then
return
end
-
+
local asn_score,total_asn,
country_score,total_country,
ipnet_score,total_ipnet,
@@ -317,12 +310,22 @@ local ip_score_check = function(task)
local ip = task:get_from_ip()
if ip:is_valid() then
+ -- Check IP whitelist
if whitelist then
if whitelist:get_key(task:get_from_ip()) then
-- Address is whitelisted
return
end
end
+ -- Check ASN & country whitelist
+ if asn_cc_whitelist then
+ if asn_cc_whitelist:get_key(country) then
+ return
+ end
+ if asn_cc_whitelist:get_key(asn) then
+ return
+ end
+ end
local cmd, args = create_get_command(ip, asn, country, ipnet)
local upstream = upstreams:get_upstream_by_hash(
@@ -349,6 +352,9 @@ local configure_ip_score_module = function()
if options['whitelist'] then
whitelist = rspamd_config:add_radix_map(opts['whitelist'])
end
+ if options['asn_cc_whitelist'] then
+ asn_cc_whitelist = rspamd_config:add_hash_map(opts['asn_cc_whitelist'])
+ end
end
end