aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-05-07 15:37:58 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-05-07 15:41:24 +0100
commit13ea9586dae5ae002c020eee62e95a0ecba65a37 (patch)
tree773b63a3fb1bd0723c443ef9cd8f24b0f5d25f0d /src
parent5437468bec5c771c75efddf7ff0fc8e26433937a (diff)
downloadrspamd-13ea9586dae5ae002c020eee62e95a0ecba65a37.tar.gz
rspamd-13ea9586dae5ae002c020eee62e95a0ecba65a37.zip
[Fix] Use better sharding for ip_score
Updating: true
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 083556066..d861b4806 100644
--- a/src/plugins/lua/ip_score.lua
+++ b/src/plugins/lua/ip_score.lua
@@ -53,22 +53,28 @@ local options = {
servers = '', -- list of servers
lower_bound = 10, -- minimum number of messages to be scored
metric = 'default',
+ old_shard = false,
min_score = nil,
max_score = nil,
score_divisor = 1,
}
local function ip_score_hash_key(asn, country, ipnet, ip)
- -- We use the most common attribute as hashing key
- if country then
- return country
- elseif asn then
- return asn
- elseif ipnet then
- return ipnet
- else
- return ip:to_string()
+ if options.old_shard then
+ if country then
+ return country
+ elseif asn then
+ return asn
+ elseif ipnet then
+ return ipnet
+ else
+ return ip:to_string()
+ end
end
+
+ -- Better sharding
+ return string.format('%s:%s:%s:%s', asn, country, ipnet,
+ ip:to_string())
end
local function ip_score_get_task_vars(task)