Skip to content

Relay: end-to-end encrypted sessions to this computer (computer side) - #313

Open
flyworker wants to merge 6 commits into
mainfrom
feat/relay-host
Open

flyworker wants to merge 6 commits into
mainfrom
feat/relay-host

Conversation

@flyworker

Copy link
Copy Markdown
Contributor

Lets a paired phone reach this computer through a relay, with no VPN and no open port. The computer keeps one outgoing connection to the relay; each phone session is end-to-end encrypted between the phone and the computer, so the relay only forwards ciphertext.

This is the computer side. The phone side (a relay route in the app) follows in a separate PR.

  • packages/relay-session: Noise_XK_25519_ChaChaPoly_BLAKE2s (@noble/curves, @noble/hashes, @noble/ciphers), one Noise message per WebSocket message, and a stream multiplexer that carries HTTP requests and WebSockets with per-stream flow control. No Node-only APIs, so the phone app can use it too.
  • Server: libraos-next relay connect <url> --token <token> stores the relay token and a static host key in the state directory. The server keeps a control socket open (reconnecting with backoff), opens a session per phone, and passes each stream to itself on loopback.
  • Who gets in: a phone whose key is on the computer's paired list, or one presenting a single-use pairing code (10 minutes) on first contact. Anything else is closed before a byte reaches the server. The server's own sign-in still applies on top.
  • Pairing links: with a relay connected, the pairing URL also carries the relay, host id, host key and a device token, in the URL fragment.
  • Docs: "Reach this computer through a relay" in docs/user/remote-access.md.

Testing

check-changed passes: format, lint, knip, typecheck and tests. Tests cover the Noise handshake against a published test vector, a wrong host key, a tampered frame, unpaired devices and used or expired pairing codes, HTTP and WebSocket streams through an in-process relay, and flow control.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant