ip黑白名单支持配置网段来过滤
parent
b5505917bf
commit
e07cb445ac
4
init.lua
4
init.lua
|
@ -225,7 +225,7 @@ function whiteip()
|
||||||
if next(ipWhitelist) ~= nil then
|
if next(ipWhitelist) ~= nil then
|
||||||
clientIp = getClientIp()
|
clientIp = getClientIp()
|
||||||
for _,ip in pairs(ipWhitelist) do
|
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
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -237,7 +237,7 @@ function blockip()
|
||||||
if next(ipBlocklist) ~= nil then
|
if next(ipBlocklist) ~= nil then
|
||||||
clientIp = getClientIp()
|
clientIp = getClientIp()
|
||||||
for _,ip in pairs(ipBlocklist) do
|
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)
|
ngx.exit(403)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue