luci-mod-status: add vendor info in index file

In the overview page are all active dhcp leases displayed.
For easier recognition, the listed MAC addresses fo these leases are
resolved to their vendor names.

Signed-off-by: Christian Korber <ck@dev.tdt.de>
This commit is contained in:
Christian Korber
2025-09-09 10:51:56 +02:00
committed by Paul Donald
parent b8fcdb0dee
commit 7b07b93ff9
2 changed files with 33 additions and 6 deletions

View File

@@ -11,6 +11,17 @@ var callLuciDHCPLeases = rpc.declare({
expect: { '': {} }
});
var callUfpList = rpc.declare({
object: 'fingerprint',
method: 'fingerprint',
});
var checkUfpInstalled = rpc.declare({
object: 'file',
method: 'stat',
params: [ 'path' ]
});
return baseclass.extend({
title: '',
@@ -19,10 +30,17 @@ return baseclass.extend({
load: function() {
return Promise.all([
checkUfpInstalled('/usr/sbin/ufpd')
]).then(data => {
var promises = [
callLuciDHCPLeases(),
network.getHostHints(),
data[0].type === 'file' ? callUfpList() : null,
L.resolveDefault(uci.load('dhcp'))
]);
];
return Promise.all(promises);
});
},
handleCreateStaticLease: function(lease, ev) {
@@ -64,6 +82,7 @@ return baseclass.extend({
leases6 = Array.isArray(data[0].dhcp6_leases) ? data[0].dhcp6_leases : [],
machints = data[1].getMACHints(false),
hosts = uci.sections('dhcp', 'host'),
macaddr = data[2],
isReadonlyView = !L.hasViewPermission();
for (var i = 0; i < hosts.length; i++) {
@@ -94,6 +113,7 @@ return baseclass.extend({
cbi_update_table(table, leases.map(L.bind(function(lease) {
var exp, rows;
var vendor;
if (lease.expires === false)
exp = E('em', _('unlimited'));
@@ -110,10 +130,15 @@ return baseclass.extend({
else if (lease.hostname)
host = lease.hostname;
if (macaddr) {
var lowermac = lease.macaddr.toLowerCase();
vendor = macaddr[lowermac].vendor ? macaddr[lowermac].vendor : null;
}
rows = [
host || '-',
lease.ipaddr,
lease.macaddr,
vendor ? lease.macaddr + ` (${vendor})` : lease.macaddr,
exp
];

View File

@@ -33,7 +33,9 @@
"description": "Grant access to DHCP status display",
"read": {
"ubus": {
"luci-rpc": [ "getDHCPLeases" ]
"luci-rpc": [ "getDHCPLeases" ],
"fingerprint": [ "fingerprint" ],
"file": [ "stat" ]
}
}
},