mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-30 07:59:35 +00:00
Improved getMacHosts() MAC lookup
This commit is contained in:
parent
441f6dd2bd
commit
dec7504d5e
2 changed files with 22 additions and 17 deletions
|
|
@ -34,26 +34,31 @@ function printMacHosts(mac)
|
|||
return ''
|
||||
end
|
||||
|
||||
function getMacHosts(mac)
|
||||
function getMacHosts(mac, additional_ip)
|
||||
local mac_hosts = interface.getMacHosts(mac)
|
||||
local num_hosts = table.len(mac_hosts)
|
||||
local url, hosts
|
||||
|
||||
if num_hosts > 0 then
|
||||
local first_host
|
||||
|
||||
for _, h in pairsByKeys(mac_hosts, asc) do
|
||||
first_host = h
|
||||
break
|
||||
end
|
||||
|
||||
url = ntop.getHttpPrefix().."/lua/hosts_stats.lua?mac="..mac
|
||||
|
||||
if num_hosts == 1 then
|
||||
hosts = first_host["ip"]
|
||||
elseif num_hosts > 1 then
|
||||
hosts = i18n("n_more_objects", { label = first_host["ip"], num = num_hosts, object = i18n("hosts")})
|
||||
end
|
||||
if(additional_ip ~= nil) then
|
||||
mac_hosts[additional_ip] = {}
|
||||
mac_hosts[additional_ip]["ip"] = additional_ip
|
||||
end
|
||||
|
||||
if(num_hosts > 0) then
|
||||
local first_host
|
||||
|
||||
for _, h in pairsByKeys(mac_hosts, asc) do
|
||||
first_host = h
|
||||
break
|
||||
end
|
||||
|
||||
url = ntop.getHttpPrefix().."/lua/hosts_stats.lua?mac="..mac
|
||||
|
||||
if num_hosts == 1 then
|
||||
hosts = first_host["ip"]
|
||||
elseif num_hosts > 1 then
|
||||
hosts = i18n("n_more_objects", { label = first_host["ip"], num = num_hosts, object = i18n("hosts")})
|
||||
end
|
||||
end
|
||||
|
||||
return hosts, url
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue