aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-09-02 17:22:20 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-09-02 17:22:20 +0100
commita28dee7044abee93a1fbf715589181b602552661 (patch)
tree9f1f43fcb85fd0371f6853ef08e07ba880736017
parentf134854580a3ac56d909e8f8404799ae45b5326a (diff)
parentdd6b0d5aabf146c1a09e503f2ac6cf1f6631da32 (diff)
downloadrspamd-a28dee7044abee93a1fbf715589181b602552661.tar.gz
rspamd-a28dee7044abee93a1fbf715589181b602552661.zip
Merge pull request #354 from fatalbanana/patch
Allow ip_score to ignore selected ASNs/countries
-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