From 7e9868f50e1c3bdb51e00bac4b529f1b327867ca Mon Sep 17 00:00:00 2001 From: Codinget Date: Sun, 2 Aug 2026 01:32:15 +0000 Subject: [PATCH] fix(tsconnect/wasm): filter offline and unreachable drive peers listDrivePeers only checked PeerCapabilityTaildriveSharer, which is usually granted to a whole group or tag, so it returned most of the tailnet including offline peers and peers with no reachable peerAPI. Apply the same conjunction as LocalBackend.driveRemotesFromPeers. Co-Authored-By: Claude Opus 5 --- cmd/tsconnect/wasm/drive.go | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/cmd/tsconnect/wasm/drive.go b/cmd/tsconnect/wasm/drive.go index 58a659e5c..dea1b53f8 100644 --- a/cmd/tsconnect/wasm/drive.go +++ b/cmd/tsconnect/wasm/drive.go @@ -240,10 +240,14 @@ type jsDrivePeer struct { Online *bool `json:"online,omitempty"` } -// listDrivePeers returns a JSON array of peers that carry -// PeerCapabilityTaildriveSharer. Returns an empty array if the local node -// does not have drive:access in its ACL (DriveAccessEnabled). This mirrors -// the filtering in LocalBackend.driveRemotesFromPeers. +// listDrivePeers returns a JSON array of peers that are online, have a +// reachable peerAPI and carry PeerCapabilityTaildriveSharer. Returns an empty +// array if the local node does not have drive:access in its ACL +// (DriveAccessEnabled). This mirrors the filtering in +// LocalBackend.driveRemotesFromPeers. +// +// The cap means a peer is allowed to share with us, not that it currently +// exposes any share, so the result is a superset of the peers with shares. func (i *jsIPN) listDrivePeers() js.Value { return makePromise(func() (any, error) { if !i.lb.DriveAccessEnabled() { @@ -269,6 +273,13 @@ func (i *jsIPN) listDrivePeers() js.Value { peers := make([]jsDrivePeer, 0) for _, p := range nm.Peers { + if !p.Online().Get() { + continue + } + peerURL := buildPeerAPIURL(p, selfHave4, selfHave6) + if peerURL == "" { + continue + } // Check PeerCapabilityTaildriveSharer via the live PeerCaps map // (derived from ACL rules), mirroring driveRemotesFromPeers. hasCap := false @@ -281,7 +292,6 @@ func (i *jsIPN) listDrivePeers() js.Value { if !hasCap { continue } - peerURL := buildPeerAPIURL(p, selfHave4, selfHave6) online := p.Online().Clone() peers = append(peers, jsDrivePeer{ Name: p.DisplayName(false), -- 2.54.0