]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Restore old style ratelimits support
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 25 Nov 2017 13:17:00 +0000 (13:17 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 25 Nov 2017 13:17:00 +0000 (13:17 +0000)
src/plugins/lua/ratelimit.lua

index 217c361718cc7a6559bbebbb02c8860034460e6c..33c38c4db80ed9ed00514cd0496c7ad7e79a1212 100644 (file)
@@ -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