]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Simple mechanism for disabling RBLs in local.d/rbl.conf 834/head
authorAndrew Lewis <nerf@judo.za.org>
Wed, 10 Aug 2016 14:50:17 +0000 (16:50 +0200)
committerAndrew Lewis <nerf@judo.za.org>
Wed, 10 Aug 2016 14:50:17 +0000 (16:50 +0200)
src/plugins/lua/rbl.lua

index 2a004201960e7de26cb1a72849cb8676fb3924c7..0ccfa440554dde73a2d0a9414c2dd58658a7365c 100644 (file)
@@ -379,91 +379,94 @@ local id = rspamd_config:register_symbol({
 })
 
 for key,rbl in pairs(opts['rbls']) do
-  for default, default_v in pairs(default_defaults) do
-    if(rbl[default_v[2]] == nil) then
-      rbl[default_v[2]] = opts[default]
+  (function()
+    if rbl['disabled'] then return end
+    for default, default_v in pairs(default_defaults) do
+      if(rbl[default_v[2]] == nil) then
+        rbl[default_v[2]] = opts[default]
+      end
     end
-  end
-  if type(rbl['returncodes']) == 'table' then
-    for s,_ in pairs(rbl['returncodes']) do
-      if type(rspamd_config.get_api_version) ~= 'nil' then
-        rspamd_config:register_symbol({
-          name = s,
-          parent = id,
-          type = 'virtual'
-        })
-
-        if rbl['dkim'] then
-          need_dkim = true
-        end
-        if(rbl['is_whitelist']) then
-          if type(rbl['whitelist_exception']) == 'string' then
-            if (rbl['whitelist_exception'] ~= s) then
-              table.insert(white_symbols, s)
-            end
-          elseif type(rbl['whitelist_exception']) == 'table' then
-            local foundException = false
-            for _, e in pairs(rbl['whitelist_exception']) do
-              if e == s then
-                foundException = true
-                break
+    if type(rbl['returncodes']) == 'table' then
+      for s,_ in pairs(rbl['returncodes']) do
+        if type(rspamd_config.get_api_version) ~= 'nil' then
+          rspamd_config:register_symbol({
+            name = s,
+            parent = id,
+            type = 'virtual'
+          })
+
+          if rbl['dkim'] then
+            need_dkim = true
+          end
+          if(rbl['is_whitelist']) then
+            if type(rbl['whitelist_exception']) == 'string' then
+              if (rbl['whitelist_exception'] ~= s) then
+                table.insert(white_symbols, s)
               end
-            end
-            if not foundException then
-              table.insert(white_symbols, s)
+            elseif type(rbl['whitelist_exception']) == 'table' then
+              local foundException = false
+              for _, e in pairs(rbl['whitelist_exception']) do
+                if e == s then
+                  foundException = true
+                  break
+                end
+              end
+              if not foundException then
+                table.insert(white_symbols, s)
+              end
+            else
+                table.insert(white_symbols, s)
             end
           else
-              table.insert(white_symbols, s)
-          end
-        else
-          if rbl['ignore_whitelists'] == false then
-            table.insert(black_symbols, s)
+            if rbl['ignore_whitelists'] == false then
+              table.insert(black_symbols, s)
+            end
           end
         end
       end
     end
-  end
-  if not rbl['symbol'] and
-    ((rbl['returncodes'] and rbl['unknown']) or
-    (not rbl['returncodes'])) then
-      rbl['symbol'] = key
-  end
-  if type(rspamd_config.get_api_version) ~= 'nil' and rbl['symbol'] then
-    rspamd_config:register_symbol({
-      name = rbl['symbol'],
-      parent = id,
-      type = 'virtual'
-    })
-
-    if rbl['dkim'] then
-      need_dkim = true
+    if not rbl['symbol'] and
+      ((rbl['returncodes'] and rbl['unknown']) or
+      (not rbl['returncodes'])) then
+        rbl['symbol'] = key
     end
-    if(rbl['is_whitelist']) then
-          if type(rbl['whitelist_exception']) == 'string' then
-            if (rbl['whitelist_exception'] ~= rbl['symbol']) then
-              table.insert(white_symbols, rbl['symbol'])
-            end
-          elseif type(rbl['whitelist_exception']) == 'table' then
-            local foundException = false
-            for _, e in pairs(rbl['whitelist_exception']) do
-              if e == s then
-                foundException = true
-                break
+    if type(rspamd_config.get_api_version) ~= 'nil' and rbl['symbol'] then
+      rspamd_config:register_symbol({
+        name = rbl['symbol'],
+        parent = id,
+        type = 'virtual'
+      })
+
+      if rbl['dkim'] then
+        need_dkim = true
+      end
+      if(rbl['is_whitelist']) then
+            if type(rbl['whitelist_exception']) == 'string' then
+              if (rbl['whitelist_exception'] ~= rbl['symbol']) then
+                table.insert(white_symbols, rbl['symbol'])
               end
-            end
-            if not foundException then
+            elseif type(rbl['whitelist_exception']) == 'table' then
+              local foundException = false
+              for _, e in pairs(rbl['whitelist_exception']) do
+                if e == s then
+                  foundException = true
+                  break
+                end
+              end
+              if not foundException then
+                table.insert(white_symbols, rbl['symbol'])
+              end
+            else
               table.insert(white_symbols, rbl['symbol'])
             end
-          else
-            table.insert(white_symbols, rbl['symbol'])
-          end
-    else
-      if rbl['ignore_whitelists'] == false then
-        table.insert(black_symbols, rbl['symbol'])
+      else
+        if rbl['ignore_whitelists'] == false then
+          table.insert(black_symbols, rbl['symbol'])
+        end
       end
     end
-  end
-  rbls[key] = rbl
+    rbls[key] = rbl
+  end)()
 end
 for _, w in pairs(white_symbols) do
   for _, b in pairs(black_symbols) do