Watchdog and Monitor looked the partner up by exact key, and the remote probe passed a quote to cut as a filename

This commit is contained in:
Gmer4Lfe
2026-08-22 00:59:24 -04:00
parent 0f228020ef
commit a89b704fa1
3 changed files with 31 additions and 10 deletions
+14 -5
View File
@@ -199,15 +199,24 @@ function vv_pt_ts_peers(): array {
// none — server1 must never resolve to server10 because it happens to share a prefix, and this
// is never similarity scoring. Same rule as vv_resolve_tailscale_ip(), which applies it to
// `tailscale status` text rather than to the parsed peer array.
function vv_pt_peer_lookup(array $tsPeers, string $hostname): array {
// The matching rule itself, separated from the value it looks up, because the peer map is not
// always the same shape: include/monitor.php keys hostname => bool while everything else keys
// hostname => array. Four call sites had each written their own exact-key lookup and all four
// rendered this mesh's partner as dark. Returns the matching KEY, or null.
function vv_pt_peer_match(array $peerNames, string $hostname): ?string {
$label = strtolower($hostname);
if (isset($tsPeers[$label])) return $tsPeers[$label];
if (in_array($label, $peerNames, true)) return $label;
$cand = [];
foreach ($tsPeers as $peerName => $peer) {
if (str_starts_with($peerName, $label) || str_starts_with($label, $peerName)) $cand[] = $peer;
foreach ($peerNames as $peerName) {
if (str_starts_with($peerName, $label) || str_starts_with($label, $peerName)) $cand[] = $peerName;
}
return count($cand) === 1 ? $cand[0] : ['online' => null, 'active' => false, 'ip' => null];
return count($cand) === 1 ? $cand[0] : null;
}
function vv_pt_peer_lookup(array $tsPeers, string $hostname): array {
$key = vv_pt_peer_match(array_keys($tsPeers), $hostname);
return $key !== null ? $tsPeers[$key] : ['online' => null, 'active' => false, 'ip' => null];
}
// ── SSH helper — run a single command on a remote host ────────────────────────