Added and fixed host location in nEdge (#9681)

This commit is contained in:
Matteo Biscosi 2025-09-22 13:45:50 +02:00
parent 03570377c1
commit 9772c8f0e7
13 changed files with 411 additions and 26 deletions

View file

@ -37,6 +37,7 @@ local pool = _GET["pool"]
local country = _GET["country"]
local os_ = tonumber(_GET["os"])
local mac = _GET["mac"]
local mac_location = _GET["location"]
local c_order = true
local lua_order = asc
@ -108,7 +109,7 @@ local mapping_column_lua_c = {
local hosts_stats = hosts_retrv_function(false, mapping_column_lua_c[sort_column], length, start, c_order, country, os_, tonumber(vlan),
tonumber(asn), tonumber(network), mac, tonumber(pool), tonumber(ipversion), tonumber(protocol), traffic_type_filter,
filtered_hosts, blacklisted_hosts, anomalous, dhcp_hosts, cidr, device_ip, true --[[ Array format ]])
filtered_hosts, blacklisted_hosts, anomalous, dhcp_hosts, cidr, device_ip, true --[[ Array format ]], false, mac_location)
for key, value in pairs(hosts_stats["hosts"]) do
local record = {}
@ -176,6 +177,11 @@ for key, value in pairs(hosts_stats["hosts"]) do
record.hostname.alt_name = alt_name
end
if ntop.isnEdge() and value["mac"] then
local mac_info = interface.getMacInfo(value["mac"])
record["location"] = mac_info.location
end
column_ip["mac"] = {
address = value["mac"],
name = getDeviceName(value["mac"])

View file

@ -313,4 +313,36 @@ if (not isEmptyString(mac)) then
}
end
if ntop.isnEdge() then
local location_list = {
{
key = "location",
value = "all",
label = i18n('hosts_stats.all')
},
{
key = "location",
value = "wan",
label = i18n('nedge.wan')
},
{
key = "location",
value = "lan",
label = i18n('nedge.lan')
},
{
key = "location",
value = "unknown",
label = i18n('unknown')
}
}
rsp[#rsp + 1] = {
action = "location",
label = i18n("hosts_stats.location"),
name = "location",
value = location_list
}
end
rest_utils.answer(rest_utils.consts.success.ok, rsp)