diff options
author | Andrew Lewis <nerf@judo.za.org> | 2017-08-30 13:42:12 +0200 |
---|---|---|
committer | Andrew Lewis <nerf@judo.za.org> | 2017-08-30 13:42:12 +0200 |
commit | 7ea56e5b36a5c4d21c23d8f2f5b2f3da7694deb7 (patch) | |
tree | c2bcad85e8eb8232c51457718e8e93c8e39a1601 /src | |
parent | 8c045e1416977693b31c9ed086fcbb3b3b71aa8d (diff) | |
download | rspamd-7ea56e5b36a5c4d21c23d8f2f5b2f3da7694deb7.tar.gz rspamd-7ea56e5b36a5c4d21c23d8f2f5b2f3da7694deb7.zip |
[Minor] Ratelimit: support use of redis HSET for limits
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/lua/ratelimit.lua | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/plugins/lua/ratelimit.lua b/src/plugins/lua/ratelimit.lua index b8d211ae7..e25ea42db 100644 --- a/src/plugins/lua/ratelimit.lua +++ b/src/plugins/lua/ratelimit.lua @@ -38,6 +38,7 @@ local rl_prefix = 'RL' local ip_score_lower_bound = 10 local ip_score_ham_multiplier = 1.1 local ip_score_spam_divisor = 1.1 +local limits_hash local message_func = function(_, limit_type) return string.format('Ratelimit "%s" exceeded', limit_type) @@ -511,13 +512,21 @@ local function ratelimit_cb(task) return process_buckets(task, args) end end + local params, method + if limits_hash then + params = {limits_hash, rspamd_lua_utils.unpack(redis_keys)} + method = 'HMGET' + else + method = 'MGET' + params = redis_keys + end local requested_keys = rspamd_redis_make_request(task, redis_params, -- connect params nil, -- hash key true, -- is write collect_cb, --callback - 'MGET', -- command - redis_keys -- arguments + method, -- command + params -- arguments ) if not requested_keys then rspamd_logger.errx(task, 'got error connecting to redis') @@ -678,6 +687,10 @@ if opts then message_func = assert(load(opts['message_func']))() end + if opts['limits_hash'] then + limits_hash = opts['limits_hash'] + end + redis_params = rspamd_parse_redis_server('ratelimit') if not redis_params then rspamd_logger.infox(rspamd_config, 'no servers are specified, disabling module') |