update 2026-09-04 03:02:09

This commit is contained in:
action committed 2026-09-04 03:02:09 +08:00
1 parent 029903be2e
commit e28fd0631a
10 files changed
+25 -17

No files matched your search

@@ -16,25 +16,34 @@ return view.extend({
load: function () {
return Promise.all([
this.callHostHints(),
fs.read('/proc/net/arp')
this.callHostHints()
]);
},
parseArp: function (data) {
var lines = data.split('\n'),
hosts = [];
parseHostHints: function (data) {
var hosts = [];
for (var i = 1; i < lines.length; i++) {
var columns = lines[i].replace(/ +/g, ' ').split(' ');
Object.keys(data || {}).forEach(function (mac) {
var hint = data[mac] || {},
ipaddrs = hint.ipaddrs || hint.ipv4 || [];
if (columns.length >= 6) {
hosts.push({
ip: columns[0],
mac: columns[3]
});
}
}
if (!Array.isArray(ipaddrs))
ipaddrs = [ ipaddrs ];
ipaddrs.forEach(function (ip) {
var octets = (typeof(ip) === 'string' && /^\d{1,3}(\.\d{1,3}){3}$/.test(ip))
? ip.split('.').map(Number) : [];
if (octets.length === 4 && octets.every(function (octet) {
return octet >= 0 && octet <= 255;
})) {
hosts.push({
ip: ip,
mac: mac
});
}
});
});
// Sort hosts array by IP address
hosts.sort(function (a, b) {
@@ -62,8 +71,7 @@ return view.extend({
},
render: function (data) {
var arpData = data[1],
hosts = this.parseArp(arpData),
var hosts = this.parseHostHints(data[0]),
m, s, o,
programPath = '/usr/share/wechatpush/wechatpush';