mirror of
https://gitee.com/iresty/apisix.git
synced 2024-12-05 05:27:35 +08:00
chore(ip-restriction): remove redundant length check (#4865)
They are guaranteed by the schema check. Signed-off-by: spacewander <spacewanderlzx@gmail.com>
This commit is contained in:
parent
fc377a92f8
commit
7b527443ee
@ -67,7 +67,7 @@ function _M.check_schema(conf)
|
||||
end
|
||||
|
||||
-- we still need this as it is too complex to filter out all invalid IPv6 via regex
|
||||
if conf.whitelist and #conf.whitelist > 0 then
|
||||
if conf.whitelist then
|
||||
for _, cidr in ipairs(conf.whitelist) do
|
||||
if not core.ip.validate_cidr_or_ip(cidr) then
|
||||
return false, "invalid ip address: " .. cidr
|
||||
@ -75,7 +75,7 @@ function _M.check_schema(conf)
|
||||
end
|
||||
end
|
||||
|
||||
if conf.blacklist and #conf.blacklist > 0 then
|
||||
if conf.blacklist then
|
||||
for _, cidr in ipairs(conf.blacklist) do
|
||||
if not core.ip.validate_cidr_or_ip(cidr) then
|
||||
return false, "invalid ip address: " .. cidr
|
||||
@ -91,7 +91,7 @@ function _M.restrict(conf, ctx)
|
||||
local block = false
|
||||
local remote_addr = ctx.var.remote_addr
|
||||
|
||||
if conf.blacklist and #conf.blacklist > 0 then
|
||||
if conf.blacklist then
|
||||
local matcher = lrucache(conf.blacklist, nil,
|
||||
core.ip.create_ip_matcher, conf.blacklist)
|
||||
if matcher then
|
||||
@ -99,7 +99,7 @@ function _M.restrict(conf, ctx)
|
||||
end
|
||||
end
|
||||
|
||||
if conf.whitelist and #conf.whitelist > 0 then
|
||||
if conf.whitelist then
|
||||
local matcher = lrucache(conf.whitelist, nil,
|
||||
core.ip.create_ip_matcher, conf.whitelist)
|
||||
if matcher then
|
||||
|
Loading…
Reference in New Issue
Block a user