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

pull/108/head
陈文江 2016-09-06 21:27:38 +08:00
parent 314a2f62ec
commit b5505917bf
1 changed files with 4 additions and 2 deletions

View File

@ -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