mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-30 07:59:35 +00:00
Handles UI network discovery requests
This commit is contained in:
parent
717b2dfa40
commit
ae828f9465
5 changed files with 157 additions and 86 deletions
|
|
@ -191,6 +191,30 @@ end
|
|||
|
||||
-- ################################################################################
|
||||
|
||||
local function getRequestNetworkDiscoveryKey(ifid)
|
||||
return "ntopng.cache.ifid_"..ifid..".network_discovery_requested"
|
||||
end
|
||||
|
||||
-- ################################################################################
|
||||
|
||||
function discover.requestNetworkDiscovery(ifid)
|
||||
ntop.setCache(getRequestNetworkDiscoveryKey(ifid), "true")
|
||||
end
|
||||
|
||||
-- ################################################################################
|
||||
|
||||
function discover.clearNetworkDiscovery(ifid)
|
||||
ntop.delCache(getRequestNetworkDiscoveryKey(ifid))
|
||||
end
|
||||
|
||||
-- ################################################################################
|
||||
|
||||
function discover.networkDiscoveryRequested(ifid)
|
||||
return ntop.getCache(getRequestNetworkDiscoveryKey(ifid)) == "true"
|
||||
end
|
||||
|
||||
-- ################################################################################
|
||||
|
||||
function discover.printDeviceTypeSelector(device_type, field_name)
|
||||
device_type = tonumber(device_type)
|
||||
|
||||
|
|
@ -629,7 +653,9 @@ function discover.discover2table(interface_name, recache)
|
|||
if recache ~= true then
|
||||
local cached = ntop.getCache(discover.getCachedDiscoveryKey(interface_name))
|
||||
if not isEmptyString(cached) then
|
||||
return json.decode(cached) or {}
|
||||
return json.decode(cached) or {status = discoverStatus("ERROR", i18n("discover.error_unable_to_decode_json"))}
|
||||
else
|
||||
return {status = discoverStatus("NOCACHE", i18n("discover.error_no_discovery_cached"))}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue