diff --git a/files/app/partial/local-and-neighbor-devices.ut b/files/app/partial/local-and-neighbor-devices.ut
index d6f1bf78..25e6e26d 100755
--- a/files/app/partial/local-and-neighbor-devices.ut
+++ b/files/app/partial/local-and-neighbor-devices.ut
@@ -40,6 +40,9 @@
}
function calcColor(tracker)
{
+ if (!tracker) {
+ return "unknown";
+ }
if (tracker.blocked) {
if (tracker.blocks.user) {
return "blocked by user";
@@ -62,7 +65,10 @@
return "idle";
}
const quality = tracker.quality;
- if (quality < 40) {
+ if (!type(quality)) {
+ return "unknown";
+ }
+ else if (quality < 40) {
return "bad";
}
else if (quality < 50) {
@@ -78,9 +84,11 @@
return "excellent";
}
};
- function calcBitrate(txbitrate, rxbitrate)
+ function calcBitrate(tracker)
{
+ const txbitrate = tracker.tx_bitrate;
if (txbitrate) {
+ const rxbitrate = tracker.rx_bitrate;
if (rxbitrate) {
return sprintf("%.1f", ((txbitrate + rxbitrate) * 5 + 0.5) / 10);
}
@@ -105,42 +113,61 @@
{%
- const trackers = lqm.getTrackers();
const llist = [];
const nlist = [];
const hlist = lqm.getHidden();
- for (mac in trackers) {
- const tracker = trackers[mac];
- if (tracker.hostname || (tracker.ip && tracker.routable)) {
- if (tracker.type === "DtD" && tracker.distance < 100) {
- push(llist, { name: tracker.hostname || `|${tracker.ip}`, mac: mac });
+ const t = lqm.getTrackers();
+ const trackers = {};
+ for (mac in t) {
+ const tmac = t[mac];
+ if (tmac.ip) {
+ trackers[tmac.ip] = tmac;
+ }
+ }
+ const links = olsr.getLinks();
+ for (let i = 0; i < length(links); i++) {
+ const link = links[i];
+ const tracker = trackers[link.remoteIP];
+ if (link.ifName === "br-dtdlink") {
+ if (tracker && tracker.distance >= 100) {
+ push(nlist, { name: tracker.hostname || `|${link.remoteIP}`, tracker: tracker, link: link });
}
else {
- push(nlist, { name: tracker.hostname || `|${tracker.ip}`, mac: mac });
+ push(llist, { name: (tracker && tracker.hostname) || `|${link.remoteIP}`, tracker: tracker, link: link });
}
}
+ else {
+ push(nlist, { name: (tracker && tracker.hostname) || `|${link.remoteIP}`, tracker: tracker, link: link });
+ }
}
if (length(llist) > 0) {
sort(llist, (a, b) => a.name == b.name ? 0 : a.name < b.name ? -1 : 1);
for (let i = 0; i < length(llist); i++) {
- const tracker = trackers[llist[i].mac];
+ const entry = llist[i];
+ const tracker = entry.tracker;
+ const link = entry.link;
const status = calcColor(tracker);
- print(`
`);
- const link = links[tracker.ip] || {};
- const lq = link.lossMultiplier ? (min(100, int(100 * link.linkQuality * 65536 / link.lossMultiplier)) + "%") : "-";
- const nlq = link.lossMultiplier ? (min(100, int(100 * link.neighborLinkQuality * 65536 / link.lossMultiplier)) + "%") : "-";
- if (tracker.hostname) {
- print(`
`);
+ if (tracker) {
+ print(`
`);
}
else {
- print(`
`);
+ print(`
`);
+ }
+ const lq = link.lossMultiplier ? (min(100, int(100 * link.linkQuality * 65536 / link.lossMultiplier)) + "%") : "-";
+ const nlq = link.lossMultiplier ? (min(100, int(100 * link.neighborLinkQuality * 65536 / link.lossMultiplier)) + "%") : "-";
+ if (substr(entry.name, 0, 1) !== "|") {
+ print(`
`);
+ }
+ else {
+ const ip = substr(entry.name, 1);
+ print(`
`);
}
print("
");
if (!request.mobile) {
- print(`
${lq}
${nlq}
${100 - tracker.quality}%
`);
+ print(`
${lq}
${nlq}
${type(tracker && tracker.quality) ? (100 - tracker.quality) + "%" : "-"}
`);
}
else {
- print(`
${lq}
${nlq}
${100 - tracker.quality}%
`);
+ print(`
${lq}
${nlq}
${type(tracker && tracker.quality) ? (100 - tracker.quality) + "%" : "-"}
`);
}
print("
");
}
@@ -158,15 +185,21 @@
if (length(nlist) > 0) {
sort(nlist, (a, b) => a.name == b.name ? 0 : a.name < b.name ? -1 : 1);
for (let i = 0; i < length(nlist); i++) {
- const tracker = trackers[nlist[i].mac];
+ const entry = nlist[i];
+ const tracker = entry.tracker;
+ const link = entry.link;
const status = calcColor(tracker);
- print(`
`);
- const link = links[tracker.ip] || {};
+ if (tracker) {
+ print(`
`);
+ }
+ else {
+ print(`
`);
+ }
const lq = link.lossMultiplier ? (min(100, int(100 * link.linkQuality * 65536 / link.lossMultiplier)) + "%") : "-";
const nlq = link.lossMultiplier ? (min(100, int(100 * link.neighborLinkQuality * 65536 / link.lossMultiplier)) + "%") : "-";
let icon = "";
let title = "";
- switch (tracker.type) {
+ switch (tracker && tracker.type || "Unknown") {
case "RF":
title = "RF ";
icon = "wifi";
@@ -190,24 +223,30 @@
default:
break;
}
- if (tracker.hostname) {
- print(`
`);
+ if (substr(entry.name, 0, 1) !== "|") {
+ print(`
`);
}
else {
- print(`
`);
+ const ip = substr(entry.name, 1);
+ print(`
`);
}
print("
");
- let d = "-";
- if ("distance" in tracker) {
- d = units.meters2distance(tracker.distance);
- if (d < 1) {
- d = "< 1";
- }
- else {
- d = sprintf("%.1f", d);
+ if (tracker) {
+ let d = "-";
+ if ("distance" in tracker) {
+ d = units.meters2distance(tracker.distance);
+ if (d < 1) {
+ d = "< 1";
+ }
+ else {
+ d = sprintf("%.1f", d);
+ }
}
+ print(`
${lq}
${nlq}
${tracker.snr || "-"}
${tracker.rev_snr || "-"}
${type(tracker.quality) ? (100 - tracker.quality) + "%" : "-"}
${calcBitrate(tracker)}
${d}
`);
+ }
+ else {
+ print(`
${lq}
${nlq}
`);
}
- print(`
${lq}
${nlq}
${tracker.snr || "-"}
${tracker.rev_snr || "-"}
${100 - tracker.quality}%
${calcBitrate(tracker.tx_bitrate, tracker.rx_bitrate)}
${d}
`);
print("
");
}
}
diff --git a/files/usr/local/bin/mgr/lqm.lua b/files/usr/local/bin/mgr/lqm.lua
index 52cd8a28..2768647d 100755
--- a/files/usr/local/bin/mgr/lqm.lua
+++ b/files/usr/local/bin/mgr/lqm.lua
@@ -126,7 +126,7 @@ function should_nonpair_block(track)
end
function should_ping(track)
- if not track.ip or is_user_blocked(track) or track.lastseen < now then
+ if not track.ip or is_user_blocked(track) or track.lastseen < now or track.firstseen == track.lastseen then
return false
end
if track.type == "Tunnel" or track.type == "Wireguard" then