luci-base: network.js: implement Hosts.getMACHints()

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
Jo-Philipp Wich 2019-09-13 14:18:43 +02:00
parent 3734f88c35
commit 2dd17fad6c

View file

@ -1307,6 +1307,18 @@ Hosts = L.Class.extend({
if (this.hosts[mac].ipv6 == ip6addr)
return mac;
return null;
},
getMACHints: function(preferIp6) {
var rv = [];
for (var mac in this.hosts) {
var hint = this.hosts[mac].name ||
this.hosts[mac][preferIp6 ? 'ipv6' : 'ipv4'] ||
this.hosts[mac][preferIp6 ? 'ipv4' : 'ipv6'];
rv.push([mac, hint]);
}
return rv.sort(function(a, b) { return a[0] > b[0] });
}
});