A Mac could install PF rules and advertise itself while IPv4 forwarding was still off. Check and enable forwarding when applying the offer and refresh the physical route when the uplink changes. Try the agent's existing privileges first. When an existing utun needs additional permission, the foreground tray or CLI can obtain an administrator grant scoped to the local UID and overlay subnet. Reconcile the current offer after the dialog so a withdrawal during authorization stays effective. A user agent denied a host utun can serve peers over bounded TCP, UDP and ICMP echo sockets bound to the physical interface. Keep host routes and ordinary local application traffic on the system-utun path. Preserve the saved choice for intentionally off-host setups and report readiness separately. Report exit selection directly to the selected peer over its authenticated session. Older peers appear for one minute following forwarded traffic. The optional announcement trailer remains compatible with control v8. Local IPC v29 carries the new status and authorization results. Keep the exit user count, left-aligned names and one-row scroll controls in a single fixed-height block alongside the network details. Show health and a small traffic trace on folded cards. Open desktop Devices at a usable width and keep the exit action clickable in its compact layout. Replace Android's per-card exit buttons with a fixed thumb-sized control. The chooser and Quick Settings share one list with a single local option, network groups, measured latency and an accessible confirmation sheet. Release the applications and packages as 1.0.9. On macOS, checked formatting, strict workspace Clippy and the workspace all-target test suite, including real encrypted agents and loopback TCP, UDP and ICMP. Ran the opt-in user-mode exit UDP round trip on a physical IPv4 interface. Verified the authorization scripts and syntax of their PF, sudoers and AppleScript components. The privileged two-utun kernel test is reserved for an isolated macOS runner. Rendered phone and desktop layouts in both themes, built the arm64 Android debug APK and cross- checked all workspace targets for Windows GNU.
124 lines
5.0 KiB
Markdown
124 lines
5.0 KiB
Markdown
# Running tsunagi on macOS
|
|
|
|
The tray and CLI run as your normal account. The packaged service creates the
|
|
system `utun` and publishes `/etc/resolver` entries. A separate user agent
|
|
with its own writable state and cache can also offer an exit through physical
|
|
TCP, UDP and ICMP echo sockets when macOS denies creation of its utun.
|
|
The system service provides the host's overlay addresses and routes.
|
|
|
|
## Quick start — `sudo`
|
|
|
|
```sh
|
|
sudo tsng up
|
|
```
|
|
|
|
In another terminal, the control commands talk to it over the system control
|
|
socket and do **not** need `sudo`:
|
|
|
|
```sh
|
|
tsng status
|
|
tsng join -n <network-name> -s <tsn1…secret>
|
|
```
|
|
|
|
The agent uses fixed system paths, so the commands find it regardless of whose
|
|
shell started `sudo`:
|
|
|
|
| what | path |
|
|
|---|---|
|
|
| mandatory state | `/var/db/tsunagi` |
|
|
| disposable cache | `/var/db/tsunagi/cache` |
|
|
| control socket | `/var/run/tsunagi/agent.sock` |
|
|
|
|
## Homebrew
|
|
|
|
```sh
|
|
brew tap house-of-vanity/tap
|
|
brew install --cask tsunagi-gui # the tray app, and the agent it needs
|
|
# or just the command line agent:
|
|
brew install tsunagi
|
|
sudo brew services start tsunagi # the agent, as a root daemon at boot
|
|
```
|
|
|
|
The cask starts the service for you. The agent runs as root, and its control
|
|
socket is open to the `admin` group, so the CLI and the tray work without
|
|
`sudo` for an administrator.
|
|
|
|
Enabling exit sharing configures IPv4 forwarding and the network's PF rules.
|
|
The system agent already has the required permissions. For a user agent with
|
|
an existing utun, the tray and CLI can request the missing permission in a
|
|
macOS administrator dialog. [Exit sharing on macOS](../../docs/exit-node.md#macos)
|
|
describes the per-user subnet grant and its removal.
|
|
|
|
After upgrading the CLI, run `sudo brew services restart tsunagi` to load the
|
|
new binary into the system daemon. Running `brew services start tsunagi` in
|
|
a user shell creates a separate launch agent. If that happened, remove the
|
|
user service with `brew services stop tsunagi`, then check the system daemon
|
|
with `sudo brew services info tsunagi`.
|
|
|
|
### Publishing Homebrew packages
|
|
|
|
After a stable `vMAJOR.MINOR.PATCH` GitHub release uploads its assets, the
|
|
`Update the Homebrew tap` job verifies the Apple Silicon archive against its
|
|
GitHub release digest and updates the `tsunagi` formula and `tsunagi-gui` cask
|
|
together on `house-of-vanity/homebrew-tap`'s `main` branch.
|
|
|
|
Set the `HOMEBREW_TAP_TOKEN` Actions secret in `house-of-vanity/tsunagi` to a
|
|
fine-grained token with **Contents: Read and write** on
|
|
`house-of-vanity/homebrew-tap`. The token must be able to push to `main`.
|
|
If publication fails, fix the reported error and rerun the Homebrew job on
|
|
the existing release workflow run.
|
|
|
|
## Native deployment — root LaunchDaemon
|
|
|
|
For an always-on agent that starts at boot, install the bundled
|
|
[`cy.hexor.tsunagi.plist`](cy.hexor.tsunagi.plist).
|
|
|
|
```sh
|
|
# Put the binary where the plist expects it (edit the plist for another path).
|
|
sudo install -m 0755 target/release/tsng /usr/local/bin/tsng
|
|
|
|
# Install the daemon. launchd refuses a daemon plist that is not owned by
|
|
# root:wheel or that is group/world-writable.
|
|
sudo install -m 0644 -o root -g wheel \
|
|
dist/macos/cy.hexor.tsunagi.plist \
|
|
/Library/LaunchDaemons/cy.hexor.tsunagi.plist
|
|
|
|
# Load and start it.
|
|
sudo launchctl bootstrap system /Library/LaunchDaemons/cy.hexor.tsunagi.plist
|
|
sudo launchctl enable system/cy.hexor.tsunagi
|
|
```
|
|
|
|
Manage it afterwards with:
|
|
|
|
```sh
|
|
sudo launchctl kickstart -k system/cy.hexor.tsunagi # restart
|
|
sudo launchctl bootout system/cy.hexor.tsunagi # stop and unload
|
|
tail -f /var/log/tsunagi.log # logs
|
|
```
|
|
|
|
The control commands (`status`, `join`, `network`, `dns`) work the same against
|
|
the daemon as against a `sudo tsng up`, over the same socket.
|
|
|
|
## What the agent does to the system
|
|
|
|
Everything it installs is tagged to its own interface, computed from local
|
|
state, and reversible — it is removed when a network leaves, broadcast is turned
|
|
off, or the agent stops:
|
|
|
|
- a **`utun` interface**, configured with `ifconfig` (addresses, MTU, up) and a
|
|
subnet `route` for the overlay range. The kernel assigns the `utunN` name; the
|
|
agent adopts whatever it is given. A `utun` is torn down with the process, so
|
|
a crash never leaves one behind.
|
|
- `/etc/resolver/<network>` files pointing the system resolver at the overlay
|
|
DNS server for each network's zone, with a `port` so the server stays off 53.
|
|
Each file carries a marker line; the agent only ever replaces or removes files
|
|
it wrote, never one you created by hand.
|
|
- while broadcast is on, a `255.255.255.255` **route** through the overlay
|
|
interface. The matching inbound-UDP firewall allowance is **not** implemented
|
|
yet (it needs a `pf` anchor); `tsng status` reports that half as incomplete
|
|
and names what to allow by hand if your host firewall drops discovery replies.
|
|
|
|
Nothing taken from a remote peer ever becomes a path, a command argument or an
|
|
OS setting: the interface name comes from the kernel, addresses and ranges from
|
|
signed state the agent already verified.
|