> Every Taji docs page as Markdown: https://docs.taji.is/llms.txt

# Tailscale: how it works

Tailscale is a mesh VPN whose Funnel feature publishes one port of a device in your tailnet to the whole internet. Taji uses it for Remote Control: your phone opens `https://taji.<tailnet>.ts.net`, the request crosses Tailscale's Funnel relays still encrypted, and TLS ends on your computer, inside Taji. The plugin has two halves. `taji-tailscale` the crate (`plugins/tailscale/src/lib.rs`) implements `taji_plugin::remote::Remote`. `taji-tailscale` the binary is a Go program (`plugins/tailscale/sidecar/main.go`) that embeds Tailscale through `tsnet` and is the only process the internet talks to. It serves no market data, places no orders and feeds no hub product. What a paired phone may do once it is in, pairing, passkeys and device tokens, is the kernel's own (`engine/crates/taji/src/wire/remote.rs`), and this page covers it because the plugin is that code's only door.

## The vendor

The facts below come from Tailscale's docs, Tailscale's Go package docs and Cloudflare's docs, all fetched 2026-12-02.

**Tailnets and machines.** A tailnet is one account's private network. Each device in it is a machine with a name, a WireGuard node key and, once HTTPS is on, a public DNS name `<machine>.<tailnet>.ts.net`. A personal tailnet is free: the Personal plan is "$0", "Free forever", "Up to 6 users" and "Unlimited user devices" ([Pricing](https://tailscale.com/pricing)). The pricing page's comparison table ticks Funnel for every plan, Personal included.

**tsnet.** "`tsnet` is a library that lets you embed Tailscale inside a Go program", on "a userspace TCP/IP networking stack" ([tsnet](https://tailscale.com/kb/1244/tsnet)). A `tsnet.Server` joins the tailnet as its own machine, with no Tailscale app installed. The fields and methods Taji uses, per the package docs ([pkg.go.dev tsnet](https://pkg.go.dev/tailscale.com/tsnet)):

- `Dir`: "the name of the directory to use for state", which holds the node key;
- `Hostname`: "the hostname to present to the control server";
- `AuthKey`: an auth key that "will be preferred over the TS_AUTHKEY environment variable". Taji sets neither, so tsnet produces "a Tailscale authentication URL" ([tsnet](https://tailscale.com/kb/1244/tsnet));
- `ListenFunnel`: "announces on the public internet using Tailscale Funnel", and "by default listens on your local tailnet" too;
- `LocalClient`: the LocalAPI client for this node;
- log upload: tsnet's logs "will automatically be uploaded to log.tailscale.com" unless the program disables it.

Taji pins `tailscale.com v1.104.7` with Go 1.27.4 (`plugins/tailscale/sidecar/go.mod`): the newest release Tailscale's changelog and stable packages publish (2026-12-02). v1.106.3 is tagged but not yet published.

**LocalAPI calls** ([pkg.go.dev client/local](https://pkg.go.dev/tailscale.com/client/local)):

| Call | What Tailscale says it does | What Taji reads from it |
|---|---|---|
| `StatusWithoutPeers` | "returns the Tailscale daemon's status, without the peer info" | `BackendState`, `AuthURL`, `Self.Expired`, `CertDomains`, `Self.KeyExpiry`, the owner's `LoginName` |
| `QueryFeature("funnel")` | "a request for instructions on how to enable a feature, such as Funnel", including "a control server URL the user can visit to enable the feature" | `URL` (a page with one press), else `Text` (why you cannot) |
| `Logout` | "logs out the current node" | nothing; it runs at unlink |

**Funnel** ([Funnel](https://tailscale.com/kb/1223/funnel)):

- It routes "traffic from the broader internet to a local service running on a device in your Tailscale network".
- "Funnel relay servers do not decrypt the traffic between public devices and your device". The node "terminates the TLS connection".
- "Funnel can only listen on ports `443`, `8443`, and `10000`", over TLS alone.
- It needs MagicDNS, HTTPS certificates and "a funnel node attribute in your tailnet policy file". A new tailnet has neither HTTPS nor the attribute; one `QueryFeature` page turns both on.
- "Tailscale Funnel is currently in beta", and its traffic "is subject to non-configurable bandwidth limits".
- "Public DNS records can take up to 10 minutes to show up for your tailnet domain."

**HTTPS certificates** ([HTTPS](https://tailscale.com/kb/1153/enabling-https)) come from Let's Encrypt, "have a 90 day expiry", and are issued under the tailnet's name. Every certificate is recorded in the public Certificate Transparency log, which "includes the fully qualified domain name of your devices". Requesting certificates too often can exceed Let's Encrypt's rate limits. The sidecar requests no certificate itself: tsnet's Funnel listener obtains it, and retries a first ACME order that comes back invalid (`main.go`'s header).

**Key expiry** ([Key expiry](https://tailscale.com/kb/1028/key-expiry)): "By default, new domains are set with an expiry period of 180 days". An expired key means "connections to/from the given endpoint will stop working". You turn expiry off per machine from the admin console's Machines page, "Disable Key Expiry".

**Device approval.** If the tailnet has device approval on, "a tailnet admin must approve the device before it joins" ([tsnet](https://tailscale.com/kb/1244/tsnet)). tsnet reports this as the `NeedsMachineAuth` backend state.

**Cloudflare DNS over HTTPS.** The sidecar checks that the public name answers through Cloudflare's JSON API: a GET with `accept: application/dns-json` and `name` and `type` parameters, answering `Status` and `Answer[]` of `{type, data}` ([DNS over HTTPS JSON](https://developers.cloudflare.com/1.1.1.1/encryption/dns-over-https/make-api-requests/dns-json/)). Cloudflare documents the hosts `cloudflare-dns.com` and `one.one.one.one` ([Make API requests](https://developers.cloudflare.com/1.1.1.1/encryption/dns-over-https/make-api-requests/)), and its JSON examples call `https://cloudflare-dns.com/dns-query`, the URL the sidecar calls.

**What Taji does not use:**

- **Tailscale Serve.** Serve reaches the tailnet alone and adds identity headers such as `Tailscale-User-Login`. "Funnel traffic, which is publicly available, does not include identity headers" ([Serve](https://tailscale.com/kb/1312/serve)). Serve would need Tailscale installed on the phone, which the user ruled out on 2026-11-21. With Funnel, the phone's identity is its passkey.
- **The Tailscale app or CLI on your computer** (`tailscale serve`, `tailscale funnel`). Taji embeds its own node, so nothing needs installing.
- **Auth keys and `TS_AUTHKEY`.** You sign in by browser. The sidecar's environment is stripped of every `TS_*` and `TAILSCALE_*` variable, so a key in your shell never signs `taji` into a tailnet you did not choose.
- **Ports 8443 and 10000.** Only 443 is served: a host typed with no scheme reaches `https:` on 443.
- **`FunnelOnly`.** The listener also answers your tailnet, and the kernel records which way each request came (`x-taji-via`).
- **Ephemeral nodes.** Not yet built. A passkey is bound to the machine's name, so the node has to keep it.
- **Tailscale's log upload.** The sidecar calls `logtail.Disable()`; the log stays on disk.
- **The `Text` that `QueryFeature` returns when you are not the tailnet's admin.** The manifest's own sentence says to ask your admin, and a tailnet you join as a member is not the one Remote Control serves; the user ruled it out on 2026-11-23.

## Code map

- `plugins/tailscale/taji-plugin.toml`: the plugin's identity, its one `[[link]]` form `tailscale` (steps `account`, `public`, `address`; `pairs = true`), the refusal sentences and the doc `sources`.
- `plugins/tailscale/src/lib.rs`: the arm. Read `impl Remote for Tailscale` first.
  - `Tailscale::default`: finds the sidecar (`TAJI_TAILSCALE_SIDECAR`, else `taji-tailscale` beside the kernel) and its state dir, `<state dir>/tailscale/`.
  - `spawn_in`: writes `offline.html`, rotates `sidecar.log` to `sidecar.log.1`, opens the new log owner-only (`0600`), strips the environment, and spawns the sidecar with `--dir`, `--to` and `--offline`, `kill_on_drop`.
  - `close`: ends the sidecar in `live`: drops its stdin, whose EOF runs `ts.Close()`, waits up to `GRACE` (10 s) for it to exit, then kills it. `spawn` closes the last sidecar before it spawns the next, under `live`'s lock, so two never share the state dir.
  - `link`: spawns a sidecar and turns its events into `Report` calls until `up` or a failure; on `up` it keeps the events in `held` for `run`, on a failure it closes the sidecar.
  - `run`: serves until the sidecar signs out or a refusal ends it, then closes it; on any other exit it closes the sidecar and respawns, the wait doubling from 1 s to `RESPAWN_CAP` (60 s), reset once a sidecar has lived `RESPAWN_RESET` (600 s).
  - `stop`: `close`, which `Control::halt` awaits.
  - `unlink`: writes `logout` to the sidecar's stdin, waits for it to exit 0, and deletes the state dir.
  - `next`, `hear`, `Event`: the JSON-line protocol.
- `plugins/tailscale/sidecar/main.go`: the sidecar. Its header comment is the protocol and the served-path list; read it first.
  - `main`, `commands`: start tsnet, poll once a second, read stdin.
  - `arm.step`, `signIn`, `consent`, `up`, `arm.bound`: status to event.
  - `reach`, `resolveDoH`, `arm.watch`, `arm.due`: the public-name probe.
  - `handler`, `server`, `peer`, `key`, `limiter`, `gauge`, `deadlines`: the internet-facing HTTP server and reverse proxy.
- `plugins/tailscale/sidecar/main_test.go`: the sidecar's tests, over a stand-in kernel.
- `plugins/tailscale/ui/mark.svg`: the mark.

Kernel code this plugin depends on:

- `engine/crates/taji-plugin/src/remote.rs`: the `Remote` trait and `Reached`.
- `engine/crates/taji-plugin/src/report.rs`: `Report`, `Said` and `Failed`, shared with channels.
- `engine/crates/taji/src/wire/remote.rs`: `Control` (the link, the row, the respawned door), `Remote` (WebAuthn, codes, device tokens, sessions) and `route` (the door's tokenless posts).
- `engine/crates/taji/src/wire/mod.rs`: `Wire::start_remote`, `Door`, `read_request` and `tokenless`, the second listener.

## How it plugs into Taji

**The trait.** `Tailscale` implements `Plugin` and registers itself with `Build::remote` (`plugins/tailscale/src/lib.rs`). `engine/crates/taji-open/src/lib.rs` adds it to the open build, and `Registry::remote` hands it to the wire, which wraps it in a `Control` (`engine/crates/taji/src/wire/mod.rs`). A build seats at most one remote arm. The `Remote` trait has four async calls; `link` and `run` are given `to`, the kernel's second loopback listener:

| Call | Contract (`engine/crates/taji-plugin/src/remote.rs`) | What Tailscale's arm does |
|---|---|---|
| `link(to, report)` | join the network, serve `to`, return `Reached {host, owner, expires_utc}` once `host` answers from the internet | spawn the sidecar; `auth` reports step `account` and its URL, `consent` reports step `public` and its URL, `resolving` reports step `address`, and `up` returns |
| `run(to, report)` | keep serving until it breaks; return why | keep `link`'s sidecar, or spawn one at a relaunch; respawn on exit; `report.reconnecting` and `report.serving` around a respawn |
| `stop()` | end what `link` or `run` left running, returning once it has; the kernel calls it once their futures are dropped | close the sidecar: stdin's EOF, up to 10 s, then a kill |
| `unlink()` | sign the machine out and delete its state | `logout`, then remove `<state dir>/tailscale/` |

No `FACTS`, `VenueFacts` or `OFFER` statics exist: the arm is neither a source nor a venue.

**The link form.** The manifest has one `[[link]]`, `form = "tailscale"`, `kind = "start"`. Its steps, refusal sentences and the after-link "Turn off key expiry" page are the manifest's, `taji-plugin.toml`. The kernel adds the last step, `pair`, because `pairs = true`. You start it from Connections, `taji-link remote`, or an agent's `ui_open` ([README](https://docs.taji.is/catalog/tailscale.md#link)).

**Surfaces and the calls behind them.** Each route's full contract is its row in the `//!` header of `engine/crates/taji/src/wire/mod.rs`.

| Taji surface | Vendor call behind it | Made in |
|---|---|---|
| `POST /verb/remote/link`, step `account` | `tsnet.Server.Start`, then `StatusWithoutPeers`: `NeedsLogin` with an `AuthURL` | `Control::link`; `Tailscale::link`; `arm.step`, `signIn` |
| step `public` | `CertDomains` empty or `ipn.NodeCanFunnel` failing, then `QueryFeature("funnel")` | `arm.step`, `consent` |
| step `address` | `ListenFunnel("tcp", ":443")`, then a DoH lookup and an HTTPS GET of the host | `arm.step`, `reach` |
| `GET /read/remote` `host`, `owner`, `expires_utc` | `CertDomains[0]`, `User[Self.UserID].LoginName`, `Self.KeyExpiry` | `up`; `Control::node` |
| `GET /read/remote` `state: reconnecting` | a probe missing 3 times a minute apart, or the sidecar exiting | `arm.watch`; `Tailscale::run`; `Control::report` |
| refusals `signed_out`, `unapproved`, `not_allowed`, `unanswered`, `stopped` | `NeedsLogin` after running or `Self.Expired`; `NeedsMachineAuth`; `QueryFeature`'s `Text`; no answer in 10 minutes; the sidecar exiting during a link | `signIn`, `consent`, `arm.bound`; `hear`, `ended` |
| `POST /verb/remote/unlink` | `Logout` | `commands`; `Tailscale::unlink`; `Control::unlink` |
| `POST /verb/remote/stop` | `tsnet.Server.Close`, run on the sidecar's stdin EOF | `Control::halt`; `Tailscale::stop`; `commands` |
| every phone request | Funnel, then TLS ended in tsnet | `handler`; `Wire::start_remote` |

`POST /verb/remote/{forget,sign_out}`, `remote/pair/options`, `remote/pair`, `remote/challenge` and `POST /app/token` call nothing of Tailscale's. They are the kernel's pairing and token routes, reachable from the phone only through this plugin.

**The trust boundaries.** The list of how the door holds is [Behaviour and limits](https://docs.taji.is/catalog/tailscale.md#behaviour-and-limits). What this plugin is responsible for:

- **TLS ends in the sidecar.** Funnel's relays carry ciphertext. Go's `net/http` is the parser the internet meets; the kernel hears only what the sidecar forwards, on a loopback port.
- **A second listener, not a header.** The kernel binds a fresh `127.0.0.1:0` port for each link (`loopback` in `engine/crates/taji/src/wire/remote.rs`) and opens the phone's door on it. That door hears only the device tokens it minted. It refuses `local`, `agent`, `page` and `sheet` tokens 401 `token`, and the loopback wire refuses device tokens (`no_local_agent_or_sheet_token_is_heard_remotely` in `engine/crates/taji/src/wire/tests.rs`).
- **The Host must be the arm's host.** Any other `Host`, or none, is 421 `host` (`a_remote_request_carries_the_arms_host_alone`).
- **Who the caller is.** The sidecar deletes any `x-taji-source` and `x-taji-via` the client sent, then sets them from the connection: a Funnel connection's original address (`ipn.FunnelConn.Src`) and `internet`, or the tailnet peer and `tailnet` (`peer` in `main.go`). The kernel keeps them on the session for the phone list (`Caller::heard`).
- **What crosses without a token.** The sidecar and the kernel each hold the same list, so neither alone decides: `GET /` (a 302 to `/app/`, answered by the sidecar), the page's files, `/app/frame/kit.css`, a symbol's logo, a keyed plugin frame, a websocket upgrade on `/ws/*` (whose first message must carry a token within 5 s), and `POST` to `remote/challenge`, `remote/pair/options`, `remote/pair` and `/app/token`. Anything else is an empty 404 (`tokenless` in `engine/crates/taji/src/wire/mod.rs`; `handler` in `main.go`). A path that the kernel's router could read differently (`..`, `//`, an escaped `/`) is never tokenless.
- **A token is judged on the head.** A request carrying `x-taji-token` passes the sidecar on any path, and the kernel refuses a wrong one 401 before reading its body. Two tokens are 400 at both ends, because Go reads the first and the kernel the last.
- **What a token is worth.** A passkey assertion buys a device token that acts as the by-hand window for 300 s, then answers 401 `passkey` to a by-hand act until Face ID again, and lapses after a day (`BY_HAND_SECS`, `TOKEN_SECS`). Minting a pairing code is by hand at the computer; the phone's door refuses `remote/link` 403 `hand`.
- **What the sidecar never gets.** It holds no wire token, sees no vault and reads no key; its environment has every `TAJI_*`, `TS_*` and `TAILSCALE_*` variable stripped (`the_sidecars_env_holds_nothing_of_tajis_or_tailscales`).
- **What stays on disk.** The node key is in `<state dir>/tailscale/`, outside the vault, because Remote Control resumes at a relaunch before you unlock. `sidecar.log` is `0600` because it holds the sign-in URL, which signs `taji` into whoever opens it first. Passkeys are in `<state dir>/remote.json` (`0600`).

**The trace: a phone's first request.** You switched Remote Control on, the link reached `up`, and you scan the QR, which opens `https://taji.<tailnet>.ts.net/app/#pair=<code>`. The fragment never leaves the phone.

1. The phone resolves the name in public DNS and connects to Tailscale's Funnel relay on 443. The relay forwards the TCP stream, still encrypted, to the node `taji`, and the TLS handshake completes there ([Funnel](https://tailscale.com/kb/1223/funnel)).
2. Inside the sidecar, tsnet's `ListenFunnel` listener hands Go's `http.Server` a TLS connection wrapping an `ipn.FunnelConn`. `ConnContext` records the source as the original client address, keyed by IPv4 address or IPv6 /48 for the caps, and `via` as `internet`.
3. `handler` reads the head, with at most 16 KiB of headers and 10 s to read them. `GET /app/` has no token and is on the tokenless list, so `forward` checks the 16-per-source and 256-in-all tokenless gauge, then hands it to `httputil.ReverseProxy`. The proxy keeps the original `Host`, sets `x-taji-source` and `x-taji-via`, and sends it to `http://127.0.0.1:<port>`, the kernel's second listener.
4. The kernel's `accept` loop for `Door::Remote` reads the request with a 30 s read timeout. `read_request` rejects a `Host` that is not the arm's host (421), a proxy request (405) or a second token (400), records the caller, and finds `/app/` on `tokenless`. The kernel serves the page.
5. The page knows from `#pair=<code>` to pair. It posts `remote/pair/options {code, name}`, which the sidecar counts against 30 tokenless POSTs a minute per source. The kernel's `route` answers the WebAuthn creation options. The phone's authenticator makes a passkey behind Face ID, and the page posts `remote/pair {code, id, credential}`. `Remote::pair` checks it with `webauthn-rs`, saves the device to `remote.json`, and answers `{token, rp_id, user_id, accepted, frames}`. The kernel frames `changed remote`, so the window's sheet ticks `pair`.
6. Every request from then on carries `x-taji-token`. The sidecar forwards it under the separate tokened gauge with a 1 MiB body cap. The kernel's `Door::device_scope` maps it to the by-hand `page` scope, and the request runs as the window's would.
7. A reply goes back the same way. The sidecar allows 120 s to write it, counted from the start of the kernel's answer. If the kernel does not answer at all, the phone gets `offline.html`, 503, `no-store`.

A later open, with no token in memory, is step 5's sign-in instead: `POST /verb/remote/challenge {}` answers discoverable request options with `allowCredentials` empty, so no credential id or count leaks, and `POST /app/token {id, credential, app}` returns the device token.

## Why it is built this way

- **Funnel, not ngrok or Cloudflare Tunnel.** Those vendors end TLS and can read the traffic. Funnel's relays do not decrypt it, so nobody but you reads your positions or your vendors' data. Cloudflare's Quick Tunnel was also rejected because its name changes at each launch, and a passkey is bound to one name.
- **Embedded tsnet, nothing on the phone.** The user ruled on 2026-11-21 that the phone runs a browser alone and that the Mac needs no Tailscale app. tsnet is a Go library, hence a Go sidecar beside a Rust kernel, built by `make sidecar` and staged beside the kernel by `engine/crates/taji/scripts/stage.sh`.
- **Go's `net/http` faces the internet.** A mature parser with header, body and time caps stands between the public address and the kernel, whose wire parser was written for loopback (`main.go`'s header).
- **A second listener, not a header.** "Remote" is which socket a request arrived on, so a forged header cannot make a local request remote or the reverse. A new port per link lets a stop close every old connection (user, 2026-11-23).
- **The passkey is the device.** WebAuthn through `webauthn-rs` 0.6.2 with user verification (`engine/crates/taji/Cargo.toml`). The relying-party id is the arm's host, so the phone holds no cookie or token at rest. The cost: renaming the machine or the tailnet orphans every passkey ([README](https://docs.taji.is/catalog/tailscale.md#if-it-fails)).
- **One consent page.** `QueryFeature("funnel")`'s URL turns on HTTPS and the `funnel` attribute with one press, which keeps the guided flow at two steps you act on.
- **The public check.** The sidecar resolves the name over Cloudflare's DoH, not the system resolver, whose MagicDNS would answer with the tailnet address and prove nothing about the internet (`answers` in `main.go`). A resolver that does not answer counts as no miss, so a network that blocks Cloudflare's DoH does not end a working door.
- **Ten minutes for the address.** Tailscale states DNS can take up to 10 minutes, and the address step took from 6 s to over five minutes when measured on 2026-11-22 ([README](https://docs.taji.is/catalog/tailscale.md#link)). Past that, something blocks it (`resolveFor`).
- **Respawn on `lost`.** A node could lose its Funnel registration while its status stayed green, and only a restart brought it back (Tailscale issue [21114](https://github.com/tailscale/tailscale/issues/21114)): after a brief control reconnect, "cleanup from the old connection was removing the node's Funnel registration that the new connection had just made". Tailscale fixed it on its coordination servers ("The fix is server-side, so there is nothing to install") and closed the issue on 2026-11-02. No client release carries the fix and a node still cannot see its own registration, so the probe and the respawn stay for a recurrence. After three misses a minute apart, `run` closes the sidecar and starts another (`lostAfter`).
- **A clean close.** Every sidecar ends by `tsnet.Server.Close` ("Close stops the server", [package `tsnet`](https://pkg.go.dev/tailscale.com/tsnet#Server.Close)), which shuts down the local backend and with it the control connection; its log flush and LocalAPI shutdown are bounded at 5 s (`tsnet/tsnet.go:665` at v1.104.7). Issue 21114 began with a control connection that ended uncleanly, there from a network blip: "the old connection can't be closed cleanly, the new one comes up immediately". So `remote/stop` and the respawn close the sidecar through its stdin and wait for it to exit, killing it only after 10 s, and the kernel opens nothing new until then (user, 2026-12-02). A kernel that dies closes the pipe, and the sidecar closes the same way.
- **The backoff.** The respawn wait doubles from 1 s to a minute and resets after ten minutes served, following Kubernetes' CrashLoopBackOff reset (`RESPAWN_RESET`).
- **The environment strip** follows Open Terminal's tunnel (`open_terminal/tunnel.py:191`, cited in `lib.rs`).
- **The caps.** Tokenless POSTs are capped per source with no total, because twenty sources could fill a total and lock your phones out. In-flight forwards are capped per source and in all, with tokened requests counted apart, so a tokenless flood cannot take an unlocked phone's acts. An IPv6 source is its /48, because a free tunnel broker hands one user a whole /48 (`limiter`, `gauge` and `key` in `main.go`).
- **Awake while serving.** A sleeping Mac's sidecar sleeps too, so the kernel runs `/usr/bin/caffeinate -s -w <pid>` while serving (`Control::open`).

## Constraints and limits

- **Funnel's own.** Beta, bandwidth limits that Tailscale does not publish, ports 443, 8443 and 10000 alone, and the public name in the Certificate Transparency log ([Funnel](https://tailscale.com/kb/1223/funnel), [HTTPS](https://tailscale.com/kb/1153/enabling-https)). Anyone reading that log knows the address; scanners asked for `/.env` and `/.git/HEAD` within a second of it appearing, which is why every unlisted path is an empty 404.
- **Key expiry.** The node signs out after 180 days unless you disable key expiry for `taji`. The sidecar reports `Self.KeyExpiry` as `expires_utc`, and the row warns from 14 days ahead ([README](https://docs.taji.is/catalog/tailscale.md#use)). On expiry, `run` ends `signed_out` and you link again, keeping the phones on the same host.
- **Admin-controlled tailnets.** Device approval gives `unapproved`, and a policy that withholds Funnel gives `not_allowed`.
- **The sidecar's caps** (`main.go`): headers 16 KiB plus Go's 4 KiB slack; tokenless body 64 KiB and tokened 1 MiB, else 413; 30 tokenless POSTs a minute per source, else 429; 16 forwards in flight per source and 256 in all, per pool, else 429; a body read within 30 s and an answer written within 120 s; no bound on waiting for the kernel, since `POST /verb/channels/link` waits for a scan.
- **The kernel's limits** (`engine/crates/taji/src/wire/remote.rs`): a pairing code lives 600 s; a ceremony 300 s and single use; at most 10,000 sign-in ceremonies outstanding, the oldest evicted, while the pairing and each device's step-up sit apart so a flood cannot evict them; device tokens are by hand for 300 s and live a day; the door sweeps revoked sockets each second.
- **The probe.** Each second until the name first answers or `unanswered` fires, then once a minute. `unanswered` comes 10 minutes after the first `resolving`, and `lost` after 3 misses in a row.
- **No identity from Tailscale.** Funnel carries none, so the kernel never trusts a Tailscale header; the passkey is the only identity.
- **Availability under flood.** 16 sources each holding 16 slow tokenless forwards fill the tokenless pool, refusing sign-ins and page loads. Only an edge could absorb that; a taji.is relay arm, a second provider of the `Remote` interface, is the answer on record and is not yet built.

## Examples

No capture yet: no test talks to Tailscale, and `remote_walk.py <port> link` against a live address would make one. The examples are test bodies at each side of the sidecar, their values made up, with each login masked as `p1`.

**The sidecar's event lines**, from `TestEventLines` in `plugins/tailscale/sidecar/main_test.go`. Each line is what one status poll emits, sent once per change:

```
{"auth":"https://login.tailscale.com/a/x"}
{"failed":{"word":"signed_out","say":"logged out"}}
{"failed":{"word":"signed_out","say":"the machine's key expired"}}
{"consent":"https://login.tailscale.com/f/funnel?node=x"}
{"failed":{"word":"not_allowed","say":"Ask your admin."}}
{"resolving":""}
{"resolving":"taji.example.ts.net"}
{"up":{"host":"taji.example.ts.net","login":"p1","expires_utc":1795000000}}
```

**What the kernel's arm makes of them.** In `link_reports_each_step_and_url_then_reaches_and_keeps_serving` (`plugins/tailscale/src/lib.rs`), a fake sidecar prints an `auth`, a non-event line, a `consent`, a `resolving` and an `up`. The arm spawns it with these arguments:

```
--dir <state dir>/tailscale --to 127.0.0.1:4321 --offline <state dir>/tailscale/offline.html
```

It reports `At("account")`, `At("account")`, `Open(<auth url>)`, `At("public")`, `Open(<consent url>)` and `At("address")`, ignoring the non-event line, and returns `Reached { host: "taji.tail-test.ts.net", owner: "p1", expires_utc: Some(1800000000) }`.

**The phone's first request at the sidecar.** In `TestTheRootRedirectsToUnlock` (`main_test.go`), `GET /` is answered by the sidecar itself, and nothing reaches the kernel:

```
GET / HTTP/1.1
→ 302 Found
Location: /app/
```

In `TestTheKernelHearsTheConnectionNotTheClientsHeaders`, a client sends `GET /app/pair` with `x-taji-source: 203.0.113.7`, a second `x-taji-source: 203.0.113.8` and `X-Taji-Via: tailnet` over a Funnel connection from `[2001:db8:1:2::9]:5000`. The kernel hears exactly one of each:

```
x-taji-source: 2001:db8:1:2::9
x-taji-via: internet
```

**The phone's door at the kernel**, from `only_a_passkey_buys_a_token_remotely` in `engine/crates/taji/src/wire/tests.rs`. Requests arrive as the sidecar forwards them, with `Host: taji.tail-test.ts.net`. The test's app answers every admitted request with its scope:

```
GET /read/desks                          (no token)
→ 404, empty body

POST /verb/remote/challenge  {}
→ 200 {"id": "…", "publicKey": {…, "allowCredentials": [], …}}

POST /app/token  {"id": "…", "credential": <assertion with a forged signature>}
→ 401 {"error": "passkey", "reason": "…"}

POST /app/token  {"id": "…", "credential": <assertion>}
→ 200 {"token": "…", "rp_id": "taji.tail-test.ts.net", "user_id": "…", "accepted": […], "frames": "…"}

GET /read/desks   x-taji-token: <that token>
→ 200 {"scope": "page", "hand": true}
```

From `a_remote_request_carries_the_arms_host_alone`, the same token with `Host: localhost`:

```
→ 421 {"error": "host", "reason": "the Host is not taji.tail-test.ts.net"}
```

## Testing

Nothing here needs a key, and no default test reaches Tailscale.

- `cargo test -p taji-tailscale`: the arm against a fake sidecar, a `sh` script that prints events and logs its arguments, environment and stdin (Unix only). It covers the link's steps and refusals, the environment strip, the log's `0600` mode and rotation, unlink's `logout`, respawn and its backoff on paused time, `reconnecting` and `serving`, `stop` closing the sidecar and killing one that outlives the grace, and a lost sidecar closing before the next spawns.
- `(cd plugins/tailscale/sidecar && go test ./...)`: the sidecar's event lines, the ten-minute bound, the probe over a fake DoH resolver and HTTPS host, and the HTTP server over a stand-in kernel: every cap, deadline, path rule, header rewrite, websocket and the offline page. The Go toolchain is the one `go.mod` names.
- `cargo test -p taji --lib -- remote`: the kernel's door and pairing, with `webauthn-authenticator-rs`'s `SoftPasskey` as the phone. `SoftPasskey` sets neither backup flag, so a synced passkey's path is unmeasured until a real phone pairs.
- `make test`: the phone page's tests under `ui/src/remote/`.
- `engine/crates/taji/scripts/remote_walk.py <port> outside|link|pair|forget`: the walk against a live address. It needs your Tailscale sign-in, Remote Control switched on in a fresh kernel (`FRESH=1 make dev`, with `TAJI_STATE_DIR` naming its state dir) and, for `pair` and `forget`, a phone. `outside` checks what a stranger gets from the public address: no token, an empty 404; a junk token, 401; two tokens, 400. Its header lists every check. It has not yet run against a live address.
- To run the kernel against a sidecar you built elsewhere, set `TAJI_TAILSCALE_SIDECAR` ([configuration](https://docs.taji.is/reference/configuration.md)).

## References

All fetched 2026-12-02.

- [Funnel](https://tailscale.com/kb/1223/funnel)
- [tsnet](https://tailscale.com/kb/1244/tsnet), [package `tsnet`](https://pkg.go.dev/tailscale.com/tsnet), [`tsnet.go` at v1.104.7](https://github.com/tailscale/tailscale/blob/v1.104.7/tsnet/tsnet.go), [package `client/local`](https://pkg.go.dev/tailscale.com/client/local)
- [HTTPS certificates](https://tailscale.com/kb/1153/enabling-https)
- [Key expiry](https://tailscale.com/kb/1028/key-expiry)
- [Serve](https://tailscale.com/kb/1312/serve)
- [Pricing](https://tailscale.com/pricing), [Versions](https://tailscale.com/kb/1168/versions), [Changelog](https://tailscale.com/changelog)
- [Issue 21114](https://github.com/tailscale/tailscale/issues/21114)
- Cloudflare: [Make API requests](https://developers.cloudflare.com/1.1.1.1/encryption/dns-over-https/make-api-requests/), [JSON format](https://developers.cloudflare.com/1.1.1.1/encryption/dns-over-https/make-api-requests/dns-json/)
- [Behaviour and limits](https://docs.taji.is/catalog/tailscale.md#behaviour-and-limits)
