From: Vsevolod Stakhov Date: Tue, 10 Apr 2018 12:54:10 +0000 (+0100) Subject: [Minor] Further key length optimization X-Git-Tag: 1.7.3~4 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=fb2d63d037216bc006538cf93e3643cb82abc51f;p=rspamd.git [Minor] Further key length optimization --- diff --git a/src/plugins/lua/ratelimit.lua b/src/plugins/lua/ratelimit.lua index 0706abc3e..935a4a247 100644 --- a/src/plugins/lua/ratelimit.lua +++ b/src/plugins/lua/ratelimit.lua @@ -358,8 +358,10 @@ local function ratelimit_cb(task) local prefix = gen_rate_key(task, k, bucket) if prefix then + local hash_len = 24 + if hash_len > #prefix then hash_len = #prefix end local hash = settings.prefix .. - string.sub(rspamd_hash.create(prefix):base32(), 1, 24) + string.sub(rspamd_hash.create(prefix):base32(), 1, hash_len) prefixes[prefix] = { bucket = bucket, name = k,