7c5ecfe50f
Add drive.go (build tag !ts_omit_drive): implements drive.FileSystemForRemote with a JS-backed handler. Streams request bodies chunk-by-chunk via readBodyChunk() and response bodies via write()/end() callbacks so no full-body buffering occurs regardless of file size. The handler is nil-safe: returns 404 until setDriveHandler() is called from JS. Add drive_stub.go (build tag ts_omit_drive): no-op stubs for stripped builds. Add peer.go: extract buildPeerAPIURL helper (previously inline in run()). Modify wasm_js.go: call initDriveForRemote before NewLocalBackend (SubSystem is set-once), expose setDriveHandler and listDrivePeers via wireDriveJS, and refactor the inline peerAPI URL logic to use buildPeerAPIURL. listDrivePeers mirrors native driveRemotesFromPeers: returns empty if DriveAccessEnabled() is false, then filters peers by PeerCapabilityTaildriveSharer using lb.PeerCaps(addr).HasCapability() (the live ACL-derived cap map). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
28 lines
681 B
Go
28 lines
681 B
Go
// Copyright (c) Tailscale Inc & contributors
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
//go:build ts_omit_drive
|
|
|
|
package main
|
|
|
|
import (
|
|
"syscall/js"
|
|
|
|
"tailscale.com/tsd"
|
|
)
|
|
|
|
type jsFileSystemForRemote struct{}
|
|
|
|
// initDriveForRemote is a no-op when the drive feature is omitted.
|
|
func initDriveForRemote(_ *tsd.System) *jsFileSystemForRemote { return nil }
|
|
|
|
// wireDriveJS is a no-op when the drive feature is omitted.
|
|
func wireDriveJS(_ *jsIPN, _ *jsFileSystemForRemote, _ map[string]any) {}
|
|
|
|
// listDrivePeers returns an empty list when the drive feature is omitted.
|
|
func (i *jsIPN) listDrivePeers() js.Value {
|
|
return makePromise(func() (any, error) {
|
|
return "[]", nil
|
|
})
|
|
}
|