Phin Tech docs Rabbit Ears Manager in the store →

A TV at another house, joined by a scan and reached over Tailscale


status: proposed #

A TV at another house, joined by a scan and reached over Tailscale

We want an Apple TV at Dad's house to be part of the station: his own profile, the same lineup, and changed from our Manager. Today that partly works already. Away from home a TV gets its settings from R2 (ADR 0001), sends edits and history through its outbox, and plays IPTV directly from the providers. What it can't do is set itself up without an invite link, which a TV can't open, or reach the server, so it gets no On Demand from the Mac mini, no relay feeds, and no status or commands.

Decisions #

  1. A TV joins by a scan. The TV shows a QR code ("Link this TV") with a one-time secret and its address on the local network. A phone already in the station scans it with the camera, which opens Rabbit Ears. You pick the TV's profiles there: for Dad, his own profile and not a manager. The phone gets the TV a device key from the server, and hands it over on the local network on the remote's connection (RemoteControl); the QR code's secret proves it's the right TV. It's the same flow for a new TV at home, and it does what docs/settings-sync.md stage 3 planned ("a new Apple TV is set up from the phone").
  2. A TV away from home reaches the server over Tailscale, not Cloudflare Access. Tailscale is the secure connection that carries video, so the TV behaves like one at home: On Demand fetched by the Mac mini, the provider VPN route and the IPTV relay (docs/iptv-relay.md), the relay's feeds, the guide, status, errors and commands. Access stays for phones (ADR 0003 decision 9) and carries no video.
  3. The TV is on our tailnet, tagged and fenced off.
    • We install and log in at setup, by scanning Tailscale's own QR code. Dad needs no account.
    • It's tagged tag:tv, so its key doesn't expire. Untagged devices expire after 180 days by default.
    • The policy lets tag:tv reach the server's port 8766 and nothing else. Only Tailscale addresses go through the tunnel, so Dad's other traffic doesn't.
  4. Video wants a direct connection. Tailscale's DERP fallback is fine for settings but not for video. UDP 41641 is forwarded to the server on our router, and tailscale ping is part of setup. Our upload speed limits how many streams leave the house (roughly 5–8 Mbps for HD).
  5. Tailscale is just another route. If the tunnel is down, the TV falls back to R2 for settings and to playing directly from the providers, as it does now. Its Settings says when it can't reach the station's server, so Dad can tell us.
  6. Commands go by the TV checking in. The server can't call into another house, so what the Manager sends a TV (reload the lineup, clear the cache, tune) waits for it. Over Tailscale the TV picks it up on its next check, every few seconds. Without Tailscale it comes from the updates Worker (decision 8).
  7. Updates come through TestFlight. We can't send dev builds to a TV that isn't on the home network, so the tvOS upload goes into app-release.
  8. Updates for devices away from home come from a Cloudflare Worker (agreed 2026-10-19). This applies to any device that can't reach the server: Dad's TV without Tailscale, and phones.
    • One Durable Object for the station holds the settings revision, each device's waiting commands, and the hashes of the device keys.
    • The Mac mini pushes to it. On every change it sends PUT /station with an admin secret: the revision, commands, and the devices (forgetting one removes its hash). These are requests going out from the house; nothing at home faces the internet.
    • Devices keep a WebSocket open to it while awake, with Authorization: Bearer <device key> and since=<rev>. The object uses the WebSocket Hibernation API, so it costs nothing while idle. A PUT wakes it, and it sends the new revision and commands down every open socket. A device then fetches the sealed settings from R2, as now.
    • Check-ins and command acknowledgements go up the same socket, and the Mac mini gets them in the reply to its next PUT. That replaces most of its outbox reading.
    • When the house is down, the Worker still answers: devices see the server is away, and commands wait.
    • A deliberate exception to Swift only (ADR 0002 decision 1): the Worker is about 100 lines of TypeScript, deployed with wrangler, and shares only a small JSON shape with the apps, not the Xtream code, the rules or the merge. Nothing else goes in it.
    • Cost: about 1,000 requests a day for three devices away from home, with check-ins counted at 20 messages to a request and messages to devices free. Duration is close to nothing. That's $0 on the free plan, or nothing beyond the $5 base on the paid plan.
  9. R2 polling becomes the safety net. A device that can't reach the server or the Worker reads the settings every 30 seconds for a few minutes after losing it or after queueing an edit, until the copy shows the edit taken. After that it reads every 5 minutes, then every 15 once an hour passes with nothing new. It also reads at once on coming to the front, waking from sleep or the screensaver, and opening the guide or channel list. The Mac mini reads only the outboxes of devices it hasn't heard from (directly or through the Worker) in the last minute.

Considered options #

Consequences #

To build #

  1. The scan: "Link this TV" on tvOS (QR code, listening for the phone), and scanning and choosing profiles on iOS.
  2. The tvOS TestFlight upload in app-release.
  3. Tailscale as a route: the server's tailnet address in the settings, tried after the home network, and the "can't reach the server" note.
  4. Commands that wait for a TV to check in.
  5. The tailnet: tag:tv, its policy, and UDP 41641 forwarded.
  6. The updates Worker:
    • the Durable Object, with hibernating WebSockets;
    • the Mac mini's PUT on each change;
    • the devices' socket (URLSessionWebSocketTask), with check-ins and command acknowledgements going up it.
  7. The R2 polling schedule (decision 9), and the Mac mini skipping outboxes of devices it has heard from.