From: Vsevolod Stakhov Date: Mon, 7 May 2018 14:37:58 +0000 (+0100) Subject: [Fix] Use better sharding for ip_score X-Git-Tag: 1.7.5~62 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=13ea9586dae5ae002c020eee62e95a0ecba65a37;p=thirdparty%2Frspamd.git [Fix] Use better sharding for ip_score Updating: true --- diff --git a/src/plugins/lua/ip_score.lua b/src/plugins/lua/ip_score.lua index 083556066e..d861b48068 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)