]> source.dussan.org Git - rspamd.git/commitdiff
Fix IP validity checks.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 10 Nov 2014 23:21:14 +0000 (23:21 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 10 Nov 2014 23:21:14 +0000 (23:21 +0000)
src/plugins/lua/ratelimit.lua

index e79f6842035b7c3150d7f84a558e42ec0201051f..afb88b4e7f15502090694eec1e40adb1b814e056 100644 (file)
@@ -131,11 +131,11 @@ end
 
 --- Make rate key
 local function make_rate_key(from, to, ip)
-       if from and ip then
+       if from and ip and ip:is_valid() then
                return string.format('%s:%s:%s', from, to, ip:to_string())
        elseif from then
                return string.format('%s:%s', from, to)
-       elseif ip then
+       elseif ip and ip:is_valid() then
                return string.format('%s:%s', to, ip:to_string())
        elseif to then
                return to
@@ -158,7 +158,7 @@ end
 local function rate_test_set(task, func)
        -- Get initial task data
        local ip = task:get_from_ip()
-       if ip and whitelisted_ip then
+       if ip and ip:is_valid() and whitelisted_ip then
                if whitelisted_ip:get_key(ip) then
                        -- Do not check whitelisted ip
                        return