mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 07:29:32 +00:00
Minor footer change
Reworked some lua utility functions
This commit is contained in:
parent
5b82594e54
commit
0d23f1aa10
3 changed files with 37 additions and 22 deletions
|
|
@ -19,6 +19,9 @@ function getInterfaceName(interface_id)
|
|||
return("")
|
||||
end
|
||||
|
||||
function getInterfaceId(interface_name)
|
||||
return(interface.name2id(interface_name))
|
||||
end
|
||||
|
||||
-- Note that ifname can be set by Lua.cpp so don't touch it if already defined
|
||||
if((ifname == nil) and (_GET ~= nil)) then
|
||||
|
|
@ -1384,6 +1387,15 @@ function tablePreferences(key, value)
|
|||
end
|
||||
|
||||
|
||||
function getInterfaceNameAlias(interface_name)
|
||||
label = ntop.getCache('ntopng.prefs.'..interface_name..'.name')
|
||||
if((label == nil) or (label == "")) then
|
||||
return(interface_name)
|
||||
else
|
||||
return(label)
|
||||
end
|
||||
end
|
||||
|
||||
function getHumanReadableInterfaceName(interface_id)
|
||||
key = 'ntopng.prefs.'..interface_id..'.name'
|
||||
custom_name = ntop.getCache(key)
|
||||
|
|
@ -1555,17 +1567,13 @@ function startswith(s, char)
|
|||
end
|
||||
|
||||
-- strsplit
|
||||
function strsplit(inputstr, sep)
|
||||
if (inputstr == nil or inputstr == "") then return {} end
|
||||
if sep == nil then
|
||||
sep = "%s"
|
||||
end
|
||||
local t={} ; i=1
|
||||
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
|
||||
t[i] = str
|
||||
i = i + 1
|
||||
end
|
||||
return t
|
||||
|
||||
function strsplit(s, delimiter)
|
||||
result = {};
|
||||
for match in (s..delimiter):gmatch("(.-)"..delimiter) do
|
||||
if(match ~= "") then result[match] = true end
|
||||
end
|
||||
return result;
|
||||
end
|
||||
|
||||
-- isempty
|
||||
|
|
@ -1586,6 +1594,15 @@ function isin(s, array)
|
|||
return false
|
||||
end
|
||||
|
||||
-- hasKey
|
||||
function hasKey(key, theTable)
|
||||
if((theTable == nil) or (theTable[key] == nil)) then
|
||||
return(false)
|
||||
else
|
||||
return(true)
|
||||
end
|
||||
end
|
||||
|
||||
-- maxRateToString
|
||||
function maxRateToString(max_rate)
|
||||
if((max_rate == nil) or (max_rate == "")) then max_rate = -1 end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue