diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-01-19 15:58:47 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-01-19 15:59:18 +0000 |
commit | a7cc997c9d8b23f01be8de752c3d05bcf07d3341 (patch) | |
tree | cd5b421aedbcb0f6ab414c3af895d1aa77bb3c79 | |
parent | 40698f757d9c0b34fd45f4b688b17e213a187a2b (diff) | |
download | rspamd-a7cc997c9d8b23f01be8de752c3d05bcf07d3341.tar.gz rspamd-a7cc997c9d8b23f01be8de752c3d05bcf07d3341.zip |
[Minor] Allow to use ratelimit as an ordinary filter
-rw-r--r-- | src/plugins/lua/ratelimit.lua | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/plugins/lua/ratelimit.lua b/src/plugins/lua/ratelimit.lua index cd9af6dfe..7f999a8c4 100644 --- a/src/plugins/lua/ratelimit.lua +++ b/src/plugins/lua/ratelimit.lua @@ -51,6 +51,7 @@ local settings = { expire = 60 * 60 * 24 * 2, -- 2 days by default limits = {}, allow_local = false, + prefilter = true, } -- Checks bucket, updating it if needed @@ -856,21 +857,24 @@ if opts then lua_util.disable_module(N, "redis") else local s = { - type = 'prefilter', + type = settings.prefilter and 'prefilter' or 'callback', name = 'RATELIMIT_CHECK', priority = 7, callback = ratelimit_cb, flags = 'empty,nostat', } - if settings.symbol then - s.name = settings.symbol - elseif settings.info_symbol then - s.name = settings.info_symbol - s.score = 0.0 + local id = rspamd_config:register_symbol(s) + + if settings.info_symbol then + rspamd_config:register_symbol{ + type = 'virtual', + name = settings.info_symbol, + score = 0.0, + parent = id + } end - rspamd_config:register_symbol(s) rspamd_config:register_symbol { type = 'idempotent', name = 'RATELIMIT_UPDATE', |