mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-30 16:09:32 +00:00
Fix interface switch while processing alerts causing alerts release to fail
getInterfaceId and getInterfaceName now do not change selected interface after the call
This commit is contained in:
parent
3410091736
commit
11517970ac
3 changed files with 27 additions and 25 deletions
|
|
@ -45,25 +45,39 @@ end
|
|||
|
||||
function getInterfaceName(interface_id, windows_skip_description)
|
||||
local ifnames = interface.getIfNames()
|
||||
local iface = ifnames[tostring(interface_id)]
|
||||
|
||||
interface_id = tonumber(interface_id)
|
||||
for _,if_name in pairs(ifnames) do
|
||||
--io.write(if_name.."\n")
|
||||
interface.select(if_name)
|
||||
_ifstats = interface.getStats()
|
||||
if(_ifstats.id == interface_id) then
|
||||
local ret = _ifstats.name
|
||||
if iface ~= nil then
|
||||
if(windows_skip_description ~= true and string.contains(iface, "{")) then -- Windows
|
||||
local old_iface = interface.getStats().id
|
||||
|
||||
if(windows_skip_description ~= true and string.contains(ret, "{")) then -- Windows
|
||||
ret = _ifstats.description
|
||||
end
|
||||
return(ret)
|
||||
-- Use the interface description instead of the name
|
||||
interface.select(tostring(iface))
|
||||
iface = interface.getStats().description
|
||||
|
||||
interface.select(tostring(old_iface))
|
||||
end
|
||||
|
||||
return(iface)
|
||||
end
|
||||
|
||||
return("")
|
||||
end
|
||||
|
||||
function getInterfaceId(interface_name)
|
||||
local ifnames = interface.getIfNames()
|
||||
|
||||
for if_id, if_name in pairs(ifnames) do
|
||||
if if_name == interface_name then
|
||||
return tonumber(if_id)
|
||||
end
|
||||
end
|
||||
|
||||
return(-1)
|
||||
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
|
||||
ifname = _GET["ifid"]
|
||||
|
|
@ -1315,18 +1329,6 @@ function http_escape(s)
|
|||
return s
|
||||
end
|
||||
|
||||
function getInterfaceId(interface_name)
|
||||
ifnames = interface.getIfNames()
|
||||
|
||||
for _,if_name in pairs(ifnames) do
|
||||
interface.select(if_name)
|
||||
_ifstats = interface.getStats()
|
||||
if(_ifstats.name == interface_name) then return(_ifstats.id) end
|
||||
end
|
||||
|
||||
return(-1)
|
||||
end
|
||||
|
||||
-- Windows fixes for interfaces with "uncommon chars"
|
||||
function purifyInterfaceName(interface_name)
|
||||
-- io.write(debug.traceback().."\n")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue