Accept CIDR in IP filters

This commit is contained in:
Alfredo Cardigliano 2023-02-01 15:43:55 +01:00
parent fb160d1b85
commit 363b48d7ae
2 changed files with 15 additions and 5 deletions

View file

@ -179,7 +179,9 @@ end
-- ##############################################
function isIPv4Network(address)
-- Check if address is a CIDR
-- strict (optional) do not accept subnets without the '/<mask>'
function isIPv4Network(address, strict)
-- Check for @ VLAN
local parts = split(address, "@")
if #parts == 2 then
@ -195,6 +197,9 @@ function isIPv4Network(address)
return false
end
elseif #parts == 1 and strict then
return false
-- Check empty
elseif #parts ~= 1 then
return false
@ -206,7 +211,9 @@ end
-- ##############################################
function isIPv6Network(address)
-- Check if address is a CIDR
-- strict (optional) do not accept subnets without the '/<mask>'
function isIPv6Network(address, strict)
-- Check for @ VLAN
local parts = split(address, "@")
if #parts == 2 then
@ -222,6 +229,9 @@ function isIPv6Network(address)
return false
end
elseif #parts == 1 and strict then
return false
-- Check empty
elseif #parts ~= 1 then
return false

View file

@ -74,19 +74,19 @@ tag_utils.defined_tags = {
operators = {'eq','neq'},
},
ip = {
value_type = 'ip',
value_type = 'cidr', -- Set to 'ip' to accept IP only
i18n_label = i18n('db_search.tags.ip'),
operators = {'eq', 'neq'},
bpf_key = 'ip host',
},
cli_ip = {
value_type = 'ip',
value_type = 'cidr', -- Set to 'ip' to accept IP only
i18n_label = i18n('db_search.tags.cli_ip'),
operators = {'eq', 'neq'},
bpf_key = 'ip host',
},
srv_ip = {
value_type = 'ip',
value_type = 'cidr', -- Set to 'ip' to accept IP only
i18n_label = i18n('db_search.tags.srv_ip'),
operators = {'eq', 'neq'},
bpf_key = 'ip host',