ip黑白名单支持配置网段来过滤
parent
b5505917bf
commit
e07cb445ac
4
init.lua
4
init.lua
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue