fix(tsconnect/wasm): filter offline and unreachable drive peers #18
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user