]> source.dussan.org Git - rspamd.git/commitdiff
Fix rbl module registration.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 21 Nov 2013 14:46:46 +0000 (14:46 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 21 Nov 2013 14:46:46 +0000 (14:46 +0000)
src/plugins/lua/multimap.lua
src/plugins/lua/rbl.lua

index f3d3ef2054e22c4c92cb0aabe0aaf08af39d3b69..229d594cfb607696177a7cdaee5be2c593199efa 100644 (file)
@@ -3,14 +3,7 @@
 local rules = {}
 
 local function ip_to_rbl(ip, rbl)
-       octets = ip:inversed_str_octets()
-       local str = ''
-       for _,o in ipairs(octets) do
-               str = str .. o .. '.'
-       end
-       str = str .. rbl
-
-       return str
+       return table.concat(ip:inversed_str_octets(), ".") .. '.' .. rbl
 end
 
 local function check_multimap(task)
@@ -73,9 +66,14 @@ local function check_multimap(task)
                        end
                elseif rule['type'] == 'dnsbl' then
                        local ip = task:get_from_ip()
-                       if ip then
-                               task:get_resolver():resolve_a(task:get_session(), task:get_mempool(),
-                                       ip_to_rbl(ip, rule['map']), multimap_rbl_cb, rule['map'])
+                       if ip and ip ~= "0.0.0.0" then
+                               if ip:get_version() == 6 and rule['ipv6'] then
+                                       task:get_resolver():resolve_a(task:get_session(), task:get_mempool(),
+                                               ip_to_rbl(ip, rule['map']), multimap_rbl_cb, rule['map'])
+                               elseif ip:get_version() == 4 then
+                                       task:get_resolver():resolve_a(task:get_session(), task:get_mempool(),
+                                               ip_to_rbl(ip, rule['map']), multimap_rbl_cb, rule['map'])
+                               end
                        end
                elseif rule['type'] == 'rcpt' then
                        -- First try to get rcpt field
index 946e3b367f1907ad084a64ada1fdb94d02a4eac0..8067d14f1e138ef6be96f0c87bc22208651e61f3 100644 (file)
@@ -27,7 +27,7 @@ local function rbl_cb (task)
                end
                task:inc_dns_req()
        end
-
+       
        local rip = task:get_from_ip()
        if(rip ~= "0.0.0.0") then
                for _,rbl in pairs(rbls) do
@@ -93,6 +93,6 @@ for key,rbl in pairs(opts['rbls']) do
        if type(rspamd_config.get_api_version) ~= 'nil' then
                rspamd_config:register_virtual_symbol(rbl['symbol'], 1)
        end
-       table.insert(rbls, {symbol = rbl['symbol'], rbl = rbl['rbl'], ipv6 = rbl['ipv6'], ipv4 = rbl['ipv4'], received = rbl['received'], from = rbl['from']})
-       rspamd_config:register_symbol(rbl['symbol'], 1.0, rbl_cb)
+       table.insert(rbls, rbl)
 end
+rspamd_config:register_callback_symbol_priority('RBL', 1.0, -1, rbl_cb)