From: Vsevolod Stakhov Date: Mon, 10 Nov 2014 23:21:14 +0000 (+0000) Subject: Fix IP validity checks. X-Git-Tag: 0.7.5~23 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=28973735682581bcb5c0825df562edcaa6641923;p=rspamd.git Fix IP validity checks. --- diff --git a/src/plugins/lua/ratelimit.lua b/src/plugins/lua/ratelimit.lua index e79f68420..afb88b4e7 100644 --- a/src/plugins/lua/ratelimit.lua +++ b/src/plugins/lua/ratelimit.lua @@ -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