Fix swapped host name in DHCP flows

This commit is contained in:
emanuele-f 2018-03-18 23:29:38 +01:00
parent 541fe593d1
commit 38f9f6ca67
7 changed files with 40 additions and 7 deletions

View file

@ -1530,6 +1530,12 @@ end
-- ##############################################
function getDhcpNamesKey(ifid)
return "ntopng.dhcp."..ifid..".cache"
end
-- ##############################################
-- Used to avoid resolving host names too many times
resolved_host_labels_cache = {}
@ -1551,6 +1557,16 @@ function getHostAltName(host_ip, host_mac)
alt_name = ntop.getHashCache(getHostAltNamesKey(), host_mac)
end
if isEmptyString(alt_name) and ifname ~= nil then
local key = getDhcpNamesKey(getInterfaceId(ifname))
if host_mac ~= nil then
alt_name = ntop.getHashCache(key, host_mac)
elseif isMacAddress(host_ip) then
alt_name = ntop.getHashCache(key, host_ip)
end
end
if isEmptyString(alt_name) then
alt_name = host_ip
end
@ -1579,7 +1595,7 @@ function getDeviceName(device_mac, skip_manufacturer)
if (info ~= nil) then
for x, host in pairs(info.hosts) do
if not isEmptyString(host.name) and host.name ~= host.ip then
if not isEmptyString(host.name) and host.name ~= host.ip and host.name ~= "NoIP" then
name = host.name
elseif host.ip ~= "0.0.0.0" then
name = getHostAltName(host.ip)