ip黑白名单支持配置网段来过滤

pull/108/head
陈文江 2016-09-06 21:29:41 +08:00
parent b5505917bf
commit e07cb445ac
1 changed files with 2 additions and 2 deletions

View File

@ -225,7 +225,7 @@ function whiteip()
if next(ipWhitelist) ~= nil then
clientIp = getClientIp()
for _,ip in pairs(ipWhitelist) do
if ip == clientIp or string.find(clientIp, ip) then
if ip == clientIp or string.find(clientIp, ip) == 1 then
return true
end
end
@ -237,7 +237,7 @@ function blockip()
if next(ipBlocklist) ~= nil then
clientIp = getClientIp()
for _,ip in pairs(ipBlocklist) do
if ip == clientIp or string.find(clientIp, ip) then
if ip == clientIp or string.find(clientIp, ip) == 1 then
ngx.exit(403)
return true
end