Repository navigation
Conversation
A computer publishes the Sheprd web UI, and later any local port, at a public HTTPS name under sheprd-relay.dev. The relay routes by SNI and stays a blind pipe; the computer holds a per-host wildcard issued through ACME DNS-01 against the relay's own DNS.
[High impact] The PR appears safe to merge; no blocking findings remain. SummaryThis PR adds opt-in HTTPS web shares through relays. The computer holds the certificate; the relay routes encrypted browser traffic and answers DNS. Since the previous review:
The previous findings are addressed in the current code. No new actionable issues were found. This review checked code and test coverage; it did not run tests. Diagram%%{init: {'theme': 'neutral'}}%%
flowchart LR
Browser[Browser] -->|Encrypted TLS bytes| Relay[Relay]
Relay -->|QUIC stream| Computer[Computer ends TLS]
Computer --> App[Web app]
Computer -->|DNS-01 challenge value| Relay
Relay --> DNS[Authoritative DNS]
Reviews (6) · Last reviewed commit: "fix(remote): keep the web share's owner,..." · Reviewed by Greptile |
The relay learns web shares at the protocol and hub level: a host label derived from the route, share names under a zone, a bounded ClientHello reader that finds the server name, listener messages to turn web shares on and set a DNS-01 value (QUIC 0x22/0x23, WebSocket web/acme_txt), and browsers' dials, announced as INCOMING_WEB or incoming_web with the visitor's address. Browsers are counted apart from the owner's devices and their sessions end when web shares go off, never with a change of dial keys. Status 10, unsupported, answers a relay without a zone. No transport for browsers yet.
With --web-zone, the relay opens a TCP port (--web-listen) that reads each ClientHello's server name and splices a browser reaching SHARE.HOST.ZONE to that host's listener, forwarding its TLS bytes untouched; other names go to --web-fallback with a PROXY protocol v2 header, or get an unrecognized_name alert. It also answers DNS for the zone (--web-dns, --web-address): share names resolve to the relay, the zone serves SOA, NS, and a CAA record that allows only Let's Encrypt by DNS-01, and _acme-challenge.HOST serves the value that host's listener set. /v1/info names the zone, and relay_web_visits_total counts outcomes.
compose.web.yml puts the relay on TCP 443 and DNS on 53 and moves Caddy behind it with a PROXY protocol listener (Caddyfile.web); the deploy README covers the NS delegation and checks. --web-fallback takes HOST:PORT so a container name works. PROTOCOL.md documents web shares. The zone's DNS no longer drops UDP past an address's rate, since a forged source could silence a resolver or a CA: it answers the question alone with TC set, no larger than the query, so real clients retry over TCP, where the limit holds.
Listener::set_web and set_acme send the new messages, and Pending::arrival reads either a device's dial or a browser for a web share (Visitor, with its address), whose stream starts with its TLS ClientHello. Pending::incoming keeps its meaning for existing callers. A test runs a real TLS handshake from a browser through the relay's web port to a computer holding its own certificate.
set_web(false) removed the host label's mapping whatever route held it; it now removes only its own. Caddyfile.web takes PROXY headers on :443 only, not on port 80. The plan's flow now matches the relay: clients check /v1/info for a web zone before sending web messages, since older relays close the listener; the listener learns a browser's address from incoming_web or a 0x11 stream, not a PROXY header; DNS answers empty NOERROR, never a refusal, for names in the zone without the type asked.
Collaborator
Author
|
@greptileai review |
A listener leaving or being replaced now ends its browsers' sessions; a WebSocket listener's accepted sockets did not close with its control socket, and a replacing listener starts with web shares off. Devices' sessions stay, as their keys let them in. The zone's DNS gives TCP its own allowance, so a UDP flood forged in a resolver's name, which now only gets truncated answers, cannot also close the TCP retry. The bytes read before a browser's session are sent in chunks of at most max-frame, so a WebSocket listener enforcing it accepts them.
examples/web_share.rs listens on a relay over QUIC, turns web shares on, and serves a page at SHARE.HOST.ZONE with a wildcard from a throwaway local CA standing in for the Let's Encrypt certificate DNS-01 would give. It is the reference for other apps' authors and what the PR's screenshots ran.
Collaborator
Author
|
@greptileai review |
The daemon gets each web share's wildcard from Let's Encrypt by DNS-01 through its relay; instant-acme runs on the workspace's ring provider, without its aws-lc-rs default.
With [remote] web_share = true (--web-share), the daemon serves its web app at https://SHARE.HOST.ZONE/ through the first relay that names a web zone. It turns web shares on there, gets a wildcard for *.HOST.ZONE from Let's Encrypt by DNS-01 with the value set through its listener, keeps it with the share label and the ACME account in its private state, renews it with a third of its life left, and ends each browser's TLS itself before handing it the router phones use. Only the share's own name is served; the share's origin joins the computer's origins; sheprd remote status prints its address or why it waits. --acme-directory and --acme-root point it at another ACME CA. An opt-in test gets a real certificate from Pebble against the relay's DNS and loads the web app through the relay.
The share's origin was added to the computer's origins, which are remembered, offered for pairing, and raced by phones; it is now admitted only while the share serves and never kept. Nearby pairing and the local CA's files answer 404 through the share, which has no use for them. A relay sending a browser to a session that did not turn web shares on is not followed.
Settings > Remote control gets a Web share switch under the relays, writing [remote] web_share, with a line that gives the web app's public address and a Copy address button once it serves, or why it waits. The same is config set remote.web_share true, and remote status prints it; docs/cli.md says so.
Status is kept by value in Health::Running, and the new field made that variant much larger than the others.
Collaborator
Author
|
@greptileai review |
… with it When shared relays change and another becomes first, its listener and the old first one reconnect, so the share starts there without waiting for a reconnect. A listener that stops serving the share now clears it back to waiting, unless a newer one took over, so status no longer offers a ready address during an outage. The certificate and its key are kept in one file, replaced in one rename, so a crash during renewal cannot leave a mismatched pair.
Collaborator
Author
|
@greptileai review |
…r one lock A listener that ended could pass the generation check, pause, and clear the certificate a newer listener had just installed. The generation, the served certificate, and the status now share one lock, and the certificate task names its generation, so an older listener's end or late steps never touch a newer one's share. A relay withdrawn while it was restarted for the web share no longer stays in the relay status.
Collaborator
Author
|
@greptileai review |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Web shares through relays: a computer publishes its own HTTPS server, starting with the Sheprd web UI as a PWA, at a public name under
sheprd-relay.dev, and the relay stays a blind pipe. Plan:docs/web-share-plan.md.This PR has the plan and Phase 1, the relay:
web_share): host label = first 80 bits ofSHA-256("sheprd-relay/web/v1\0" ‖ route), base32; shares atSHARE.HOST.ZONE. A bounded ClientHello reader extracts the SNI. Bit-flip and truncation loops show it never panics.web_share::edge,--web-listen): reads only the ClientHello's server name, splices a browser to its host's listener with the TLS bytes untouched, sends other names to--web-fallback(Caddy) with a PROXY v2 header, and answers unknown shares withunrecognized_name.web_share::dns,--web-dns,--web-address): an authoritative server for the zone only. A/AAAA for share names, SOA/NS, and CAAletsencrypt.org; validationmethods=dns-01at the apex, and TXT at_acme-challenge.HOSTfrom that host's listener. NXDOMAIN inside the zone, REFUSED outside it. Over the rate limit, UDP gets a TC=1 reply (the address may be forged) and TCP has the hard limit.web/acme_txt, QUIC0x22/0x23). Browsers are counted apart from the owner's devices (64 per route) and have their own rate. Their sessions end when web shares go off, never on a dial-key change. New status 10unsupported./v1/infogainsweb.zone.Listener::set_web,set_acme,Pending::arrival→Arrival::Web(Visitor).Pending::incomingis unchanged for existing callers.compose.web.yml+Caddyfile.web(the relay takes TCP 443 and port 53, Caddy moves behind it). README covers NS delegation and checks.PROTOCOL.md"Web shares",vectors/web_share.json.Phase 2, the computer (
sheprd-remote-control, behind[remote] web_share = true):/v1/infois read with the connection (client::reach_with_info); nothing about web shares is sent to a relay that names no zone, and status saysno_zone.instant-acme(ring) gets*.HOST.ZONEfrom Let's Encrypt by DNS-01, the value set through the daemon's own listener (set_acme). The label, account (per CA directory), chain, and key are kept 0600 underweb-share/, renewed with a third of life left, retried 15 min → 6 h.--acme-directoryand--acme-rootpoint it at staging or a private CA.config set remote.web_share truedoes the same, andremote statusprintsWeb share: URL(JSONstatus.web).Trust note: rate limits key browsers by the address their relay reports, and the share origin is only as trusted as its relay's zone, as the plan's threat section says.
Without
--web-zone, relays behave exactly as before; without[remote] web_share, the daemon does too.Not in this PR: pairing a browser from the share's origin, a Let's Encrypt staging run on a delegated zone,
client_wslistener support, the dashboard kill switch, and the PSL entry for*.sheprd-relay.dev.Screenshots
Real usage in a Sheprd macOS VM:
sheprd-relay --web-zone fra1.sheprd-relay.devon TCP 443, with macOS's resolver for the zone pointed at the relay's own DNS (/etc/resolver), andexamples/web_share.rsas the computer. It listens over QUIC, turns web shares on, and ends TLS itself. Its wildcard comes from a throwaway local CA standing in for the Let's Encrypt certificate Phase 2 gets by DNS-01.Safari opens the share with no certificate warning. The page is served by the computer over TLS 1.3, and the relay only carried the bytes:
The same name resolved by macOS through the relay's DNS, the zone's CAA record, the computer's wildcard certificate as curl sees it, and the relay counting spliced visits:
Settings > Remote control, from this branch's debug build in a Sheprd VM: the Web share switch under the relays, on, with its status line (remote control is off there, so it says it starts with it; once running it shows the address with Copy address, or why it waits):
QA
cargo test -p sheprd-relay --all-features: 281 passedcargo test -p sheprd-remote-control: 1,927 passed, including a browser through a loopback relay to the daemon's router with TLS ended in the daemonweb_share::tests::pebblewith Pebble v2.10.3: a real ACME DNS-01 order answered by the relay's DNS through the daemon's listener, then the web app loaded trusting only Pebble's root (4.4 s)cargo test -p sheprd-gpui --libfor the new status line and Settings row;just check-i18n, including a real TLS handshake browser → edge → relay → QUIC listener holding its own certificatecargo clippy -p sheprd-relay --all-targets --all-features: cleancargo checkof--no-default-features --features client,websocket-server, andtesting, plus every crate that depends onsheprd-relayswift testincrates/sheprd-relay/swift: 25 passed (new status 10)python3 scripts/test_relay_deploy.py: 25 passed.docker compose -f compose.yml -f compose.web.yml configmerges as intendedjust check-file-size,git diff --checkdigagainst--web-dnsreturned A/AAAA, CAA, SOA, NXDOMAIN, and REFUSED as specified;/v1/infoshowsweb.zoneCaddyfile.webvalidated by Caddy (the Docker daemon was down here)fra1.sheprd-relay.dev, thendig +norec @IP a.aaaaaaaaaaaaaaaa.fra1.sheprd-relay.devand check the relay's own HTTPS still works through the fallbackcrates/sheprd-relay/ci.sh)