diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-11-25 13:17:00 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-11-25 13:17:00 +0000 |
commit | 9467740fff260eeeaf34aef3782ffd3e4afb923f (patch) | |
tree | 5a58ccd8ab60c94fc7a016b4d13e4ab48690ff56 | |
parent | 6af040cf2949ce0eebe52121efef6bb3ce4bcc54 (diff) | |
download | rspamd-9467740fff260eeeaf34aef3782ffd3e4afb923f.tar.gz rspamd-9467740fff260eeeaf34aef3782ffd3e4afb923f.zip |
[Fix] Restore old style ratelimits support
-rw-r--r-- | src/plugins/lua/ratelimit.lua | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/plugins/lua/ratelimit.lua b/src/plugins/lua/ratelimit.lua index 217c36171..33c38c4db 100644 --- a/src/plugins/lua/ratelimit.lua +++ b/src/plugins/lua/ratelimit.lua @@ -616,12 +616,24 @@ if opts then fun.each(function(t, lim) if type(lim) == 'table' then settings[t] = {} - fun.each(function(l) - local plim, size = parse_string_limit(l) - if plim then - table.insert(settings[t], {plim, size}) + if #lim == 2 and tonumber(lim[1]) and tonumber(lim[2]) then + -- Old style ratelimit + rspamd_logger.warnx(rspamd_config, 'old style ratelimit for %s', t) + if tonumber(lim[1]) > 0 and tonumber(lim[2]) > 0 then + table.insert(settings[t], {1.0/lim[2], lim[1]}) + elseif lim[1] ~= 0 then + rspamd_logger.warnx(rspamd_config, 'invalid numbers for %s', t) + else + rspamd_logger.infox(rspamd_config, 'disable limit %s, burst is zero', t) end - end, lim) + else + fun.each(function(l) + local plim, size = parse_string_limit(l) + if plim then + table.insert(settings[t], {plim, size}) + end + end, lim) + end elseif type(lim) == 'string' then local plim, size = parse_string_limit(lim) if plim then |