mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 23:49:33 +00:00
Added support to all and port range for acl
This commit is contained in:
parent
392ff1117e
commit
72681a36dd
2 changed files with 2180 additions and 2148 deletions
50
scripts/lua/modules/validation_utils.lua
Normal file
50
scripts/lua/modules/validation_utils.lua
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
--
|
||||
-- (C) 2021 - ntop.org
|
||||
--
|
||||
local dirs = ntop.getDirs()
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
||||
|
||||
-- #################################################################
|
||||
|
||||
local validation_utils = {}
|
||||
|
||||
-- #################################################################
|
||||
|
||||
local function validateNumber(p)
|
||||
-- integer number validation
|
||||
local num = tonumber(p)
|
||||
|
||||
if (num == nil) then
|
||||
return false
|
||||
end
|
||||
|
||||
if math.floor(num) == num then
|
||||
return true
|
||||
else
|
||||
-- this is a float number
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
-- #################################################################
|
||||
|
||||
function validation_utils.validatePortRange(p)
|
||||
local v = string.split(p, "%-") or {p, p}
|
||||
|
||||
if #v ~= 2 then
|
||||
return false
|
||||
end
|
||||
|
||||
if not validateNumber(v[1]) or not validateNumber(v[2]) then
|
||||
return false
|
||||
end
|
||||
|
||||
local p0 = tonumber(v[1]) or 0
|
||||
local p1 = tonumber(v[2]) or 0
|
||||
|
||||
return (((p0 >= 1) and (p0 <= 65535)) and ((p1 >= 1) and (p1 <= 65535) and (p1 >= p0)))
|
||||
end
|
||||
|
||||
-- #################################################################
|
||||
|
||||
return validation_utils
|
||||
Loading…
Add table
Add a link
Reference in a new issue