diff --git a/init.lua b/init.lua index 2eb5966..69913b7 100644 --- a/init.lua +++ b/init.lua @@ -223,8 +223,9 @@ end function whiteip() if next(ipWhitelist) ~= nil then + clientIp = getClientIp() for _,ip in pairs(ipWhitelist) do - if getClientIp()==ip then + if ip == clientIp or string.find(clientIp, ip) then return true end end @@ -234,8 +235,9 @@ end function blockip() if next(ipBlocklist) ~= nil then + clientIp = getClientIp() for _,ip in pairs(ipBlocklist) do - if getClientIp()==ip then + if ip == clientIp or string.find(clientIp, ip) then ngx.exit(403) return true end