Repository navigation
Conversation
A second, parallel embedded-Tailscale host option backed by tailscale-rs (Rust) rather than Go libtailscale (PR #12). Because Rust has an aarch64-apple-visionos target, the feature links and runs on Vision Pro — the platform the Go path can never reach. SSH is dialed through an in-process tsnet node; no system VPN, no NetworkExtension. Backend deltas from the Go path, all driven by the rs C ABI (CTailscaleRS): - The node identity is app-owned. tailscale-rs takes the three 32-byte node keys as an input and never exports them, so the app generates them with SecRandom and persists the 96 bytes in the Keychain — the tailnet node survives launches with no plaintext state directory, satisfying the keychain-only house rule the Go path had to except. The Go force-login constructor hack is gone (the auth key is a ts_init parameter). - A tailnet connection is an opaque handle with blocking send/recv, not an fd, so the one-shot loopback relay's remote side is now a TailscaleRelayRemote protocol (handle-backed for real dials, fd-backed for the DEBUG fake dial). Citadel still dials 127.0.0.1 through its ordinary bootstrap — the inEventLoop constraint that forced the relay is unchanged. Half-close forwards through the seam; the handle has no half-close so full teardown rides relay.close() on SSHConnection.close(). - ts_init hangs on a rejected auth key, so init is raced against a 30 s deadline. TS_RS_EXPERIMENT is set before init (upstream gates the FFI on it); all peer traffic relays through public DERP today. The UI compiles on all three platforms (no visionOS-disabled apology), carries experimental/relayed copy and the missing-auth-key tip, and keeps mosh mutually exclusive for v1 (the rs UDP ABI can lift that later). The four static archives (incl. xros) are git-ignored; Tools/build-tailscale-rs.sh rebuilds them at the pinned commit + one upstream patch. Full record: local-plan/tailscale-rs-investigation.md.
Real tailnet dials failed with "unaddressable destination" and a
remote_endpoint of <peer-ip>:0 — the port never made it onto the
sockaddr. ts_parse_ip fills the address with port 0, and tailscale-rs's
ts_sockaddr_set_port is a no-op: it mutates a by-value copy of the union
field (`unsafe { addr.sa_data.sockaddr_in }.sin_port = port`, net_types.rs
:361/:365) and discards it. So the port stayed 0 for every dial.
Write sin_port/sin6_port directly onto the struct after parsing, host byte
order, keyed off the ffi's own TS_AF_INET/TS_AF_INET6 values — the pattern
the C examples use (tcp_echo.c sets .sin_port = 1234 and prints it with
%u). The fake-dial DEBUG path uses a plain kernel socket and never hit
this. Verified by build on all platforms + the upstream source; needs a
real tailnet to exercise end to end.
|
Fixed the `unaddressable destination` / `:0` dial failure (`e0a9682`). Root cause is an upstream tailscale-rs bug, not the app: `ts_sockaddr_set_port` is a no-op. It does `unsafe { addr.sa_data.sockaddr_in }.sin_port = port` — that copies the union field out by value, sets the port on the throwaway copy, and discards it (net_types.rs:361/365, both the v4 and v6 arms). `ts_parse_ip` fills the address with port 0, so with the setter doing nothing, every dial went out as `:0` and smoltcp rejected it. The app now writes `sin_port`/`sin6_port` directly onto the sockaddr after parsing — host byte order, keyed off the ffi's own `TS_AF_INET`/`TS_AF_INET6` values (2/23), matching the pattern the C examples use (`tcp_echo.c` sets `.sin_port = 1234` and prints it with `%u`). The broken ffi setter is bypassed entirely. Worth reporting upstream (their own examples avoid the setter, which is probably why it slipped through). All three platforms still build; the DEBUG fake-dial path uses a plain kernel socket so it never exercised this — needs a real tailnet dial to confirm, which is your retest. |
After the port fix, real dials reached the connect stage but failed with "no region stored in multiderp, no underlay route" then connection reset — the peer's DERP region is in the netmap, but the local node hadn't yet registered a transport for it. tailscale-rs establishes its DERP underlay (the only data path today) asynchronously after the netmap, and the C ABI exposes no readiness signal beyond ts_ipv4_addr (which unblocks at the netmap, earlier). So a dial right after startup races DERP setup. connectWithRetry retries the dial with backoff (8 × 900 ms) so the transient window self-heals as the region's Uniderp spawns and reports its transport. Bounded, so a genuinely unroutable peer still fails in ~7 s rather than hanging; each attempt logs to the tailscale category. If DERP never establishes on a device that's an upstream limit (DERP-only, no Apple netmon), not a race — needs on-device confirmation that later attempts land.
|
Progress on the real-tailnet dial (`e590a39`). The port fix worked — your second log shows `remote_endpoint: 100.77.122.118:22` (was `:0`). The new failure is a DERP-underlay readiness race, not addressing: ``` The peer's DERP region is in the netmap, but the local node hadn't registered a transport for that region yet. tailscale-rs brings up its DERP underlay (the only data path today — no direct connections) asynchronously after the netmap, and its C ABI has no "underlay ready" signal — `ts_ipv4_addr` unblocks at the netmap, which is earlier. So a dial fired right after node startup races DERP setup. The node starts lazily on the first dial, so the first attach races it hardest. Mitigation: `connectWithRetry` retries the dial with backoff (8 × 900 ms ≈ 7 s) so the window self-heals once the region's Uniderp connects and reports its transport. Each attempt logs to the `tailscale` category (stderr / Console). Please retest and watch Console: if a later attempt lands (attach succeeds within a few seconds), the race is covered. If it retries all 8 and still fails, DERP genuinely isn't establishing on your setup — that's the experimental backend's DERP-only + no-Apple-netmon limitation (investigation §1/§6), an upstream wall to raise with Tailscale rather than something I can fix app-side. The `RUST_LOG` lines (whether Uniderp connects to a DERP region at all) will tell us which. |
Main moved Add Host and Settings to UIKit, so the Tailscale toggle, missing-auth-key tip, and Settings section are ported onto the native forms (SettingsTailscaleSection). The relay dial now uses the host-key pin verifier instead of acceptAnything; pins are keyed by host id, so they bind through the 127.0.0.1 hop. New copy is localized (zh-Hant/ja, needs_review) and the DEBUG env hooks move to docs/agents/e2e-headless.md.
The node key state was a synchronizable Keychain item, so iCloud Keychain would hand every device the same node identity, and two devices running one node key fight over it. It is now a device-only item on its own service: migrateDeviceOnlyItems re-syncs every device-local item under the secrets service, so it cannot live there.
Upstream's crypto passed a third-party audit and the TS_RS_EXPERIMENT gate is gone, so the tunnel stops setting it. The one ABI change is ts_config.ephemeral; the node persists its key, so it registers as a durable (non-ephemeral) machine. Toolchains move to Rust 1.98.1 and nightly-2026-09-17 for the xros slices. The build script checks the header after the first cargo build, because ts_ffi's build.rs generates it and a fresh clone has none. The ts_netmon patch still applies and is still needed.
# Conflicts: # Multiplex/Views/Settings/SettingsView.swift # MultiplexTests/SettingsUIKitTests.swift
# Conflicts: # MultiplexTests/SettingsUIKitTests.swift # fastlane/testflight-whats-new.txt
The ts_netmon cfg patch landed upstream in v0.7.0, so the pin is now unpatched and Vendor/tailscale-rs/patches is gone (the CI cache key drops it too). Upstream moved its crates into category directories; the build script reads the generated header from crates/bindings/ts_ffi. The C ABI itself is unchanged: the vendored tailscale.h still matches. A rejected auth key behaves differently at this pin. ts_init now returns a device in about 2 s, and ts_ipv4_addr then waits for a netmap that never arrives (measured with an invalid key against a macOS build of the archive). The address read ran outside the 30 s startup deadline, so the node would have sat in STARTING for good. The deadline now covers ts_init and the address read together. MULTIPLEX_SEED_TAILSCALE=0 turns the seeded host's flag back off: it persists on the simulator's host and seed.json never reset it.
What
A second, parallel Connect via Tailscale host option — SSH through an embedded userspace tailnet node — backed by tailscale-rs (Rust) instead of the Go libtailscale used in #12. The point: Rust has an
aarch64-apple-visionostarget, so this works on Vision Pro — the platform the Go path can structurally never reach. No system VPN, no NetworkExtension.Full record + build matrix:
local-plan/tailscale-rs-investigation.md(gitignored; §7a has the v0.6.1 re-evaluation, not yet updated for v0.7.1).Upstream: tailscale-rs v0.7.1
Pinned to tag
v0.7.1(a2a56c4, 2026-11-06), unpatched: the localts_netmoncfg patch landed upstream in v0.7.0, soVendor/tailscale-rs/patchesis gone. The C ABI is unchanged from v0.6.1 (the vendoredtailscale.hstill matches); upstream only movedts_ffitocrates/bindings/ts_ffi.ts_tunnel; upstream now recommends it from a security perspective. TheTS_RS_EXPERIMENTenv gate is gone (the app no longer sets it).ts_config.ephemeral. The node persists its key, so it registers as a durable machine (ephemeral = false, set explicitly).Backend deltas from #12 (all from the rs C ABI,
CTailscaleRS)SecRandomand keeps the 96 bytes in the Keychain as a device-only item on its own service. Each device is its own tailnet node, while the auth key syncs through iCloud Keychain like other secrets.ts_tcp_send/recv, so the one-shot loopback relay's remote side is aTailscaleRelayRemoteprotocol (handle-backed for real dials, fd-backed for fake-dial). Citadel still dials127.0.0.1through its ordinary bootstrap — theconnect(on:)inEventLoop constraint that forced the relay in Experimental: Connect via Tailscale host option (iPhone/iPad) #12 is unchanged. The handle has no half-close, so teardown ridesrelay.close().HostKeyVerifieras a direct dial.ts_initreturns a device in about 2 s andts_ipv4_addrthen blocks for good (measured with an invalid key against a macOS build of the archive; through v0.6.1 it wasts_initthat hung). The 30 s deadline now coversts_initand the address read together.ts_peer_ipv4_addr→ dial by IP; literals dial directly (TailscaleRSDialAddress, pure + tested).ts_sockaddr_set_portis a no-op upstream (writes a by-value union copy); the tunnel setssin_port/sin6_portdirectly.UI
Ported onto main's UIKit forms: a Connect via Tailscale row in Add Host › Transport (mutually exclusive with mosh, missing-auth-key tip) and a Settings › Tailscale section (auth key, optional Headscale control URL, live node status; saved on Done). Copy is labelled experimental and localized (zh-Hant/ja,
needs_review).Scope
ts_udp_*), so mosh-over-tailnet is buildable later — the thing Go could never do — but it's deferred.Verified
Tools/build-tailscale-rs.sh.MULTIPLEX_SEED_TAILSCALE=1+ an invalidMULTIPLEX_TAILSCALE_AUTHKEY): the terminal ends with "Tailscale startup timed out after 30 seconds. Check the auth key." A plain-SSH attach on the same simulator still goes LIVE.MULTIPLEX_TAILSCALE_FAKE_DIAL); the investigation proved the C ABI reaches Tailscale's control plane and gets an auth verdict.Build notes
The four static archives (~20–50 MB each) are git-ignored;
Tools/build-tailscale-rs.shrebuilds them at the pin. iOS slices use Rust 1.98.1 (upstream's pin); the xros slices need nightly-2026-09-17 +-Zbuild-stdwhileaarch64-apple-visionosstays tier 3.Relationship to #12
#12 (Go) and this (Rust) are two backends for the same per-host option; if this proves out on device across all three platforms, it supersedes #12. Not intended to merge both.