From 28973735682581bcb5c0825df562edcaa6641923 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 10 Nov 2014 23:21:14 +0000 Subject: [PATCH] Fix IP validity checks. --- src/plugins/lua/ratelimit.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 -- 2.39.5