mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-30 07:59:35 +00:00
Interface name mapping with human readable name
This commit is contained in:
parent
4010b2b356
commit
017844c6a8
2 changed files with 27 additions and 22 deletions
|
|
@ -14,6 +14,26 @@ i18n.loadFile(dirs.installdir..'/scripts/locales/'..locale..'.lua')
|
|||
|
||||
-- ##############################################
|
||||
|
||||
function string.contains(String,Start)
|
||||
if type(String) ~= 'string' or type(Start) ~= 'string' then
|
||||
return false
|
||||
end
|
||||
return(string.find(String,Start,1) ~= nil)
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
function shortenString(name, max_len)
|
||||
max_len = max_len or 24
|
||||
if(string.len(name) < max_len) then
|
||||
return(name)
|
||||
else
|
||||
return(string.sub(name, 1, max_len).."...")
|
||||
end
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
function getInterfaceName(interface_id)
|
||||
local ifnames = interface.getIfNames()
|
||||
|
||||
|
|
@ -23,7 +43,12 @@ function getInterfaceName(interface_id)
|
|||
interface.select(if_name)
|
||||
_ifstats = interface.getStats()
|
||||
if(_ifstats.id == interface_id) then
|
||||
return(_ifstats.name)
|
||||
local ret = _ifstats.name
|
||||
|
||||
if(string.contains(ret, "{")) then -- Windows
|
||||
ret = shortenString(_ifstats.description, 16)
|
||||
end
|
||||
return(ret)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -181,15 +206,6 @@ end
|
|||
|
||||
-- ##############################################
|
||||
|
||||
function string.contains(String,Start)
|
||||
if type(String) ~= 'string' or type(Start) ~= 'string' then
|
||||
return false
|
||||
end
|
||||
return(string.find(String,Start,1) ~= nil)
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
function string.starts(String,Start)
|
||||
if type(String) ~= 'string' or type(Start) ~= 'string' then
|
||||
return false
|
||||
|
|
@ -251,17 +267,6 @@ end
|
|||
|
||||
-- ##############################################
|
||||
|
||||
function shortenString(name, max_len)
|
||||
max_len = max_len or 24
|
||||
if(string.len(name) < max_len) then
|
||||
return(name)
|
||||
else
|
||||
return(string.sub(name, 1, max_len).."...")
|
||||
end
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
--
|
||||
-- Returns indexes to be used for string shortening. The portion of to_shorten between
|
||||
-- middle_start and middle_end will be inside the bounds.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue