The Manager relay: live feeds fetched once for every screen
Superseded 2026-11-03. The Swift server (
StationServer,RelayServer,antenna-tower-server,control-room, the Manager's launchd helper and MCP assistant) was replaced by the Go tower intower/(ADR 0005). What follows is history.
Design agreed 2026-09-27. The relay and its first feed, planes, were built the same day; see Built at the end.
Live layers (planes, ships, lightning) come from sources with quotas, keys or one-connection terms. Today each Apple TV and the Mac app fetches for itself, so two TVs halve an OpenSky login's credits, and a source like Blitzortung or AISStream would see a connection per screen. The relay fetches each source once, in the Manager, and every screen in the house reads from it.
Decisions #
- A protocol, hosted by the Manager. Relay code talks to a small HTTP protocol, not to the Manager's windows, so the same relay could run on the homelab later without changing the TVs. For now the Manager hosts it: it runs all the time on the Mac mini, so it's effectively always on.
- Plain HTTP polling. Screens ask for a feed every few seconds and get JSON
from the relay's cache; event feeds take a
sincecursor and return only what's new. None of the sources update faster than every few seconds, so push would look the same and cost reconnect logic on every screen. Asking counts as watching: there's no subscribe step. - Found two ways. The Manager writes its address into a synced setting
(rewritten when the Mac's address changes) and advertises
_retrotv-relay._tcpover Bonjour. Screens try the synced address first (instant, and works across mesh Wi-Fi and segmented networks), then Bonjour. - Each feed says how it falls back. A feed with a free, keyless source (planes on anonymous OpenSky) fetches directly from the screen when the relay can't be reached, as today. A feed that needs the relay (a secret key, one shared connection, permission terms: ships, lightning) drops out quietly, and its layer shows as unavailable in the Select menu.
- A household token. The Manager makes a random token once and syncs it through iCloud; every request carries it and anything without it is refused. It keeps guests' devices from reading the relay or burning quotas. The data is public, so plain HTTP on the home network is fine.
The protocol #
Version 1, at http://<host>:<port>/v1. Every request sends
X-RetroTV-Token; without the right one the answer is 401.
| Request | Answer |
|---|---|
GET /v1/hello |
The relay's version and its feeds: id, kind, and whether each is running. |
GET /v1/feeds/<id>?box=minLat,minLon,maxLat,maxLon |
A snapshot feed's latest items in the box, with the time they're from. If-None-Match gets a 304 when nothing changed. |
GET /v1/feeds/<id>?box=…&since=<cursor> |
An event feed's items since the cursor (at most the last ten minutes), and the next cursor. |
- A feed that can't serve (upstream down, no key set, no permission) answers 503 with a reason; the screen then falls back as its feed says.
- Interest: each request marks its feed and box as watched for a minute. The relay merges the boxes being watched into as few upstream calls as it can (one world call when a screen is on the World page; one small box for each area page, which OpenSky prices at a credit). A feed nobody has asked for in a minute stops.
Discovery and the token #
- Synced setting
relay:{host, port, updated}, written by the Manager when it starts and when the network changes. - Bonjour
_retrotv-relay._tcp, TXTv=1. The apps already declare Bonjour and local network use for diagnostics; the relay's service type is added. - Synced setting
relayToken: 32 random bytes, made once. The Manager's Relay pane can make a new one. - A screen keeps the last address that worked, and tries it first next time.
In the code #
- Shared (
Packages/StationUI/Sources/StationUI/Relay/):RelayFeed, a feed's description: its id, kind (snapshot or events), item type, and fallback (a direct fetch, or none).RelayClientfinds the relay, adds the token, fetches, and falls back. Channel modules call it instead of fetching themselves. - Manager (
Packages/ManagerUI/Sources/ManagerUI/Relay/):RelayServer(anNWListener, sharing the HTTP code the assistant server already has), and aRelaySourcefor each feed: what it fetches upstream, for which boxes, how often. A Relay pane in Settings shows each feed: running or not, upstream calls today against its quota, and which screens asked lately. - Secrets stay on the Manager. The OpenSky login stops syncing to the screens: the relay uses it, and a screen falling back uses anonymous access. An AIS key, when there is one, lives only on the Manager too.
The first feeds #
- Planes (OpenSky): through the relay with your login; a small box for each area page, so it can refresh every half minute there. Falls back to anonymous access from the screen.
- Ships (AISStream, a free key): the relay holds one live connection subscribed to the boxes being watched, and serves ships in a box. Relay only.
- Lightning (Blitzortung, if they agree): one connection, strikes as events. Relay only.
Built (2026-09-27) #
Packages/RetroRelay, a Swift package, so the relay can also run on its own:RelayKit(plain Foundation; the Apple TV links it): the protocol types andRelayClient.RelayServer(Hummingbird, for macOS and Linux):RelayService(routes, the token check) andPlanesSource.retro-relay, the relay alone:RETRO_RELAY_TOKEN=… [OPENSKY_CLIENT_ID=… OPENSKY_CLIENT_SECRET=…] retro-relay. The Linux build hasn't been tried yet (no Docker running here); the code keeps to Foundation,FoundationNetworkingand Hummingbird so it should.
- The Manager hosts it (
RelayHost), from its window's process only, on port 8766: Bonjour, the synced address (relay) and token (relayToken), and the Relay pane in Settings (on or off, where screens find it, the token, the OpenSky login, credits and calls today, screens lately). - The OpenSky login moved to the relay. It's no longer synced (the Manager removes the old copy from iCloud) and isn't in the World pane any more.
- Screens (
RelayFinder): the synced address, then three seconds of Bonjour; a relay that answered is kept five minutes, and nothing found isn't looked for again for a minute. The World channel asks the relay for planes in the page's box every refresh (15 seconds), and falls back to anonymous OpenSky every 15 minutes when there's no relay. - Planes (
PlanesSource): boxes being watched (a minute's lease) become calls: the whole world if any box is 400 square degrees or more, else each box not inside another, split at the date line. Calls are spaced so the day's credits (4,000 with a login, 400 without) last the day with a tenth spare, never more than every ten seconds; OpenSky's "wait" is honoured.
Status and clients (2026-09-28) #
- Clients: the relay notes every request that passes the token check
against the screen that sent it (its
X-RetroTV-Screenname, else its address): address, first and last seen, what it last asked for, and how many requests./v1/hellolists the last day's (RelayClientInfo), and so does the Manager's Settings › Relay. - The Status channel (a channel module kept with the settings channels at
the end of the dial): this screen (name, address, build, iCloud sync), the
relay (where, how it was found, when this screen last connected, its feeds),
the other screens on it, and each module's live sources with how fresh they
are (
ChannelModule.statusLines()). It asks the relay afresh every ten seconds while it's on.
One relay, chosen (2026-09-28) #
- Off until you turn it on. The Manager only runs the relay where "Run the relay on this Mac" is on (the Mac mini), so two Managers don't fight over the synced address. Turning it off takes the synced address away if it was this Mac's.
- Each relay names itself in
/v1/hello(its Mac's name, orRETRO_RELAY_NAMEforretro-relay). - Screens find every relay: the synced address and all Bonjour turns up,
each asked for its hello. The Status channel lists them, and its Select menu
chooses one ("Relay: Mac mini") or Automatic (the synced one first); the
choice is kept on that screen (
relayChoice). - The Manager's Settings › Relay warns when another relay is running on the network.
- Modules can put rows of their own in their channel's Select menu
(
ChannelModule.menuItems()), besides their on/off settings.
Phin Tech docs
Rabbit Ears Manager in the store →