aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/lua/ratelimit.lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-08-19 11:55:35 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-08-19 11:55:35 +0100
commit4203d8caf65bf84106cd26bd5c058e6610ddeaf6 (patch)
treee849d2c9c0deaf5b8784a7c55abe4987089bc0e9 /src/plugins/lua/ratelimit.lua
parent0ed8564321887e7480a91276d06a0c08ddf9769b (diff)
downloadrspamd-4203d8caf65bf84106cd26bd5c058e6610ddeaf6.tar.gz
rspamd-4203d8caf65bf84106cd26bd5c058e6610ddeaf6.zip
[Minor] Combine selectors and use the proper table field in ratelimit
Diffstat (limited to 'src/plugins/lua/ratelimit.lua')
-rw-r--r--src/plugins/lua/ratelimit.lua40
1 files changed, 26 insertions, 14 deletions
diff --git a/src/plugins/lua/ratelimit.lua b/src/plugins/lua/ratelimit.lua
index d9c0f164e..8c0c48387 100644
--- a/src/plugins/lua/ratelimit.lua
+++ b/src/plugins/lua/ratelimit.lua
@@ -432,25 +432,37 @@ end
local function limit_to_prefixes(task, k, v, prefixes)
local n = 0
- for _,bucket in ipairs(v.bucket) do
- local prefix
+ for _,bucket in ipairs(v.buckets) do
if v.selector then
- prefix = lua_selectors.process_selectors(task, v.selector)
+ local selectors = lua_selectors.process_selectors(task, v.selector)
+ if selectors then
+ local combined = lua_selectors.combine_selectors(task, selectors, ':')
+ if type(combined) == 'string' then
+ prefixes[combined] = make_prefix(combined, k, bucket)
+ n = n + 1
+ else
+ fun.each(function(p)
+ prefixes[p] = make_prefix(p, k, bucket)
+ n = n + 1
+ end, combined)
+ end
+ end
else
- prefix = gen_rate_key(task, k, bucket)
- end
-
- if prefix then
- if type(prefix) == 'string' then
- prefixes[prefix] = make_prefix(prefix, k, bucket)
- n = n + 1
- else
- fun.each(function(p)
- prefixes[p] = make_prefix(p, k, bucket)
+ local prefix = gen_rate_key(task, k, bucket)
+ if prefix then
+ if type(prefix) == 'string' then
+ prefixes[prefix] = make_prefix(prefix, k, bucket)
n = n + 1
- end, prefix)
+ else
+ fun.each(function(p)
+ prefixes[p] = make_prefix(p, k, bucket)
+ n = n + 1
+ end, prefix)
+ end
end
end
+
+
end
return n