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:
@@ -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 ────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user