Add a nil check to the parse ip function (#50)
This commit is contained in:
parent
f44ea23d5e
commit
0461b74b22
1 changed files with 6 additions and 0 deletions
|
@ -151,6 +151,9 @@ local function item_to_string(item, scope)
|
||||||
end
|
end
|
||||||
|
|
||||||
local ip_network_address, is_ipv4 = iputils.parseIPAddress(ip)
|
local ip_network_address, is_ipv4 = iputils.parseIPAddress(ip)
|
||||||
|
if ip_network_address == nil then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
if is_ipv4 then
|
if is_ipv4 then
|
||||||
ip_version = "ipv4"
|
ip_version = "ipv4"
|
||||||
if cidr == nil then
|
if cidr == nil then
|
||||||
|
@ -393,6 +396,9 @@ function csmod.allowIp(ip)
|
||||||
csmod.SetupStream()
|
csmod.SetupStream()
|
||||||
|
|
||||||
local key = item_to_string(ip, "ip")
|
local key = item_to_string(ip, "ip")
|
||||||
|
if key == nil then
|
||||||
|
return true, nil, "Check failed '" .. ip .. "' has no valid IP address"
|
||||||
|
end
|
||||||
local key_parts = {}
|
local key_parts = {}
|
||||||
for i in key.gmatch(key, "([^_]+)") do
|
for i in key.gmatch(key, "([^_]+)") do
|
||||||
table.insert(key_parts, i)
|
table.insert(key_parts, i)
|
||||||
|
|
Loading…
Add table
Reference in a new issue