]> source.dussan.org Git - rspamd.git/commitdiff
Minimum netmask in Redis multimap 1753/head 1761/head
authorMichael Kuron <mkuron@users.noreply.github.com>
Sun, 16 Jul 2017 13:19:59 +0000 (15:19 +0200)
committerMichael Kuron <mkuron@users.noreply.github.com>
Sun, 16 Jul 2017 13:19:59 +0000 (15:19 +0200)
src/plugins/lua/multimap.lua

index ea3508a6063ee8989ab2d5e54e5e8c1bd8a4b634..ca32a8d217963c243e92402f6e4f5a1fc2605ae3 100644 (file)
@@ -383,11 +383,13 @@ local function multimap_callback(task, rule)
         (r['filter'] == 'real_ip' or r['filter'] == 'from_ip' or not r['filter'])) then
         srch = {value:to_string()}
         cmd = 'HMGET'
-        local bits = 128
+        local maxbits = 128
+        local minbits = 32
         if value:get_version() == 4 then
-            bits = 32
+            maxbits = 32
+            minbits = 8
         end
-        for i=bits,1,-1 do
+        for i=maxbits,minbits,-1 do
             local nip = value:apply_mask(i):to_string() .. "/" .. i
             table.insert(srch, nip)
         end