From: Vsevolod Stakhov Date: Sat, 25 Nov 2017 13:17:00 +0000 (+0000) Subject: [Fix] Restore old style ratelimits support X-Git-Tag: 1.7.0~410 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9467740fff260eeeaf34aef3782ffd3e4afb923f;p=rspamd.git [Fix] Restore old style ratelimits support --- 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