Discover LAN servers and relay authenticated browser peer connections
This commit is contained in:
+10
@@ -1265,3 +1265,13 @@ has a 20-second context, bounded Git output/time and file traversal, and at most
|
||||
100 deletion candidates. Partial scans cannot claim that the storage target has
|
||||
been reached. Cleanup refusals and limits remain visible rather than discarding
|
||||
protected data to satisfy a quota.
|
||||
|
||||
|
||||
### LAN server discovery
|
||||
|
||||
`{"type":"discover_servers"}` returns `discovered_servers` with a
|
||||
`discovered_servers` array of `{name,endpoint,auth,version}` records. The server
|
||||
browses `_pipelines._tcp.local` on its own LAN, with a bounded DNS-SD query; it
|
||||
does not scan arbitrary ports. An unavailable browse returns a protocol error.
|
||||
The authenticated web front door exposes the same result at `GET /api/discovery`,
|
||||
including before the browser has opened its application websocket.
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
# Browser discovery and simultaneous server connections
|
||||
|
||||
The server adds a bounded `discover_servers` RPC and local `/discovery` HTTP
|
||||
handler using its existing mDNS dependency. Advertisements are validated, sorted
|
||||
and deduplicated; only valid Pipelines `/connect` records are returned. The web
|
||||
front door exposes this as authenticated `GET /api/discovery`. This searches the
|
||||
hosting machine's LAN, which can differ from the browser's current network.
|
||||
|
||||
For browser federation, authenticated same-origin `POST /api/peers/:serverId`
|
||||
accepts `{endpoints:[wsURLs],password?:string}` and responds with `connected`,
|
||||
`needs_password`, and successful `connected_endpoints`. It signs into each remote
|
||||
machine directly, retaining cookies only in proxy memory, scoped to the local
|
||||
login session, server id and exact registered alias. `DELETE` revokes that server.
|
||||
A proxy restart requires signing into remote peers again; remote harness sessions
|
||||
and background work are independent and are not stopped by this relay.
|
||||
|
||||
The browser opens `/peers/:serverId/connect?endpoint=<original ws URL>` and reads
|
||||
files/artifacts/updates or uploads through `/peers/:serverId/<resource>`, using the
|
||||
same optional `endpoint` query. These are same-origin paths, so HTTPS browsers can
|
||||
reach trusted LAN servers without cross-origin cookies or mixed-content sockets.
|
||||
Local browser cookies and Origin are never forwarded to remote machines; only the
|
||||
selected peer's exact stored credential is used. No redirects are followed, no
|
||||
remote Set-Cookie is exposed, and proxying is limited to registered endpoints and
|
||||
known application resource paths. Mutating registration calls require same Origin
|
||||
and JSON, and all endpoints remain behind the local login gate.
|
||||
|
||||
New local sessions have unique nonce-bearing signed cookies, while existing
|
||||
legacy cookies remain valid. Profile edits revoke previous aliases immediately;
|
||||
registration generations prevent late responses resurrecting deleted profiles.
|
||||
Failed reauthentication to an unchanged profile preserves its existing cookie and
|
||||
websocket. Expired owner records close their sockets and are pruned before limits.
|
||||
|
||||
Verification: all 13 Node tests passed, including isolated real HTTP/WS peers,
|
||||
per-browser and per-server cookie isolation, scoped files and websocket routing,
|
||||
authenticated discovery, revocation races, failed sign-in preservation, and owner
|
||||
expiry cleanup. Go discovery/protocol/server tests and focused vet passed. All
|
||||
fixtures used loopback/scratch state; no operator sessions, passwords, deployments
|
||||
or workflows were changed. Parent owns Flutter integration and delivery.
|
||||
Reference in New Issue
Block a user