Fix macOS exit sharing and bring exit selection onto the phone home screen
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.
This commit is contained in:
1 parent
d8b7787430
commit
43894612ee
65 files changed
+3110
-654
No files matched your search
+1
-1
@@ -127,7 +127,7 @@ The internal capability is `wireguard-e2e` v4; external `wg` and `awg` use v2,
|
||||
`wg-quic` v1 and `tcp-tls` v2, as in 1.0.1. Control ALPN
|
||||
`tsunagi/ctrl/8`, discovery, membership and signed state are unchanged. The data
|
||||
ALPN is `tsunagi/data/6`; the relay envelope format is unchanged. Automatic
|
||||
carrier comparisons are optional on the mesh wire. Local IPC is v25,
|
||||
carrier comparisons are optional on the mesh wire. Local IPC is v29,
|
||||
so agent, CLI and tray must match. Historical `wg-quic/wireguard.sqlite` is the
|
||||
canonical internal key store. Missing keys are imported transactionally from
|
||||
`wg` then `awg`, without replacing an existing canonical key or modifying a
|
||||
|
||||
+34
-9
@@ -17,7 +17,8 @@ The offering side, per network, off by default:
|
||||
tsng network exit-node <network> on # or off
|
||||
```
|
||||
|
||||
Linux and macOS report kernel forwarding in `status`. To enable it on Linux:
|
||||
Linux and macOS report kernel forwarding in `status`. macOS enables it when
|
||||
the local owner offers an exit. On Linux, enable it with:
|
||||
|
||||
```sh
|
||||
sudo sysctl -w net.ipv4.ip_forward=1
|
||||
@@ -34,6 +35,7 @@ tsng exit-node off
|
||||
|
||||
The tray does the same: a checkbox on the network tile to offer, and an icon on
|
||||
each device in the devices window that offers one, with a confirmation.
|
||||
On Android the round button at the bottom right of the home screen opens all available exits, grouped by network. A check marks the current choice. **No exit node** returns to the phone’s own connection.
|
||||
The network card shows the selected peer even when folded. The up arrow counts
|
||||
IP bytes sent through the exit and the down arrow counts reply bytes delivered
|
||||
to this device. Traffic addressed to the peer within the mesh is counted only
|
||||
@@ -104,19 +106,41 @@ subnet is dropped locally. Offering an exit remains a per-network choice.
|
||||
|
||||
## macOS
|
||||
|
||||
macOS has no `iptables` and no per-user policy routing, so the same behaviour
|
||||
is built from `pf` and `route`. The agent runs as root there.
|
||||
macOS uses `pf` and `route`. The packaged system agent can configure both.
|
||||
|
||||
A user agent that cannot create a system utun can still offer an exit through
|
||||
the userspace forwarder. It opens TCP and UDP sockets on the physical uplink
|
||||
and handles ICMP echo. A system utun is required to carry traffic from local
|
||||
Mac applications over the mesh. Both modes retain the agent's own identity
|
||||
and configured networks.
|
||||
|
||||
- **Offering:** a `pf` anchor `com.apple/tsunagi-exit-<interface>` (the stock
|
||||
`/etc/pf.conf` already evaluates `com.apple/*`) holds
|
||||
`nat on <egress> from <range> to any -> (<egress>)` and tags packets entering from an offered range. A tagged packet that the
|
||||
NAT for traffic tagged on entry from an offered range. A tagged packet that the
|
||||
kernel would forward back to the utun gets a PF `route-to` through the
|
||||
physical gateway. The physical NAT state is interface-bound.
|
||||
`pf` is enabled if it was off, and that reference is released when the rules
|
||||
go. Forwarding is only read: `sudo sysctl -w net.inet.ip.forwarding=1`, which
|
||||
macOS forgets at reboot. The egress is the default route's interface **at the
|
||||
time the rules are applied**; after it changes (Wi-Fi to Ethernet) switch the
|
||||
offer off and on.
|
||||
go. After installing the rules the agent enables IPv4 forwarding and checks
|
||||
the kernel's answer before advertising the exit. Stopping the offer removes
|
||||
its rules and leaves the system-wide switch available to Internet Sharing
|
||||
and other routers. An active offer enables it again after reboot. The agent
|
||||
follows the physical default route when Wi-Fi or Ethernet changes.
|
||||
- With an existing overlay interface, a user agent first tries its own
|
||||
permissions. If the operating system denies an exit operation, an explicit
|
||||
enable from the tray or CLI can open the macOS administrator dialog. Approval
|
||||
installs a root-owned helper under `/private/etc/tsunagi-exit` and a sudoers
|
||||
entry for this user and that helper alone. Each approved overlay subnet has
|
||||
a separate grant. The helper checks the live utun address and mask, selects
|
||||
the uplink from the kernel, and manages its own PF anchor and enable token.
|
||||
It accepts only sharing operations. The agent can subsequently reconcile and
|
||||
remove these rules without prompting. At startup it reclaims orphaned helper
|
||||
anchors for the account by checking the owning process and its start time.
|
||||
For a system agent with the necessary
|
||||
rights, the initial enable completes directly.
|
||||
- To revoke a grant, turn off its offer, then remove
|
||||
`/private/etc/tsunagi-exit/grant_<uid>_<address>_<prefix>` as administrator.
|
||||
Removing `/private/etc/sudoers.d/tsunagi-exit-<uid>` revokes that user's
|
||||
access to the helper for all subnets.
|
||||
- When **using** an exit, ordinary IPv4 internet connections take the two
|
||||
split-default routes through the utun, with the local address of the selected
|
||||
network. More specific routes continue to reach their own networks.
|
||||
@@ -175,7 +199,8 @@ is built from `pf` and `route`. The agent runs as root there.
|
||||
clear. The agent logs it once, `status` and the tray say so loudly.
|
||||
- **IPv6-only destinations are unreachable** meanwhile; carrying IPv6 through
|
||||
the exit node is not implemented. DNS is untouched.
|
||||
- Kernel forwarding is only read, never changed.
|
||||
- Linux reports the administrator's kernel forwarding setting. macOS enables
|
||||
IPv4 forwarding for a local offer. Windows uses a userspace forwarder.
|
||||
|
||||
## Trust
|
||||
|
||||
|
||||
+11
-5
@@ -17,9 +17,9 @@ existing `NetworkId`.
|
||||
Control version 8 adds signed, multi-writer VIP field snapshots to version 7's
|
||||
node retirements. The transition from control v7 to v8 requires updating all
|
||||
members together. Members already on v8 can adopt the optional software version
|
||||
field independently. Data ALPN is `tsunagi/data/6` for the single internal
|
||||
and exit-use fields independently. Data ALPN is `tsunagi/data/6` for the single internal
|
||||
WireGuard channel. Network ids, derivation labels, handshake encoding and
|
||||
existing record signatures are unchanged. Local CLI/tray IPC is version 25.
|
||||
existing record signatures are unchanged. Local CLI/tray IPC is version 29.
|
||||
Restart the agent with matching clients. SQLite schema 10 adds `vip_fields`, preserving identity,
|
||||
network configuration, signed node records and retirement proofs.
|
||||
See [virtual services](vip.md), [state sync](sync-model.md) and [AWG](amnezia.md).
|
||||
@@ -250,7 +250,7 @@ not affect other networks.
|
||||
|
||||
| message | meaning |
|
||||
|---|---|
|
||||
| `Announce { broadcast, exit_node, hostname, capabilities, agent_version? }` | this agent’s hostname, capabilities, broadcast and exit settings, and optional software release |
|
||||
| `Announce { broadcast, exit_node, hostname, capabilities, agent_version?, uses_your_exit? }` | this agent’s hostname, capabilities, broadcast and exit settings, and optional software release |
|
||||
| `Transport { protocol, payload }` | private, bounded per-peer transport negotiation; never state or a public message event |
|
||||
| `Ping { seq, payload }` | small request used to verify the exchange |
|
||||
| `Pong { seq, payload }` | the echoed reply |
|
||||
@@ -260,14 +260,20 @@ not affect other networks.
|
||||
| `Reachable { links }` | sender's current direct data links, by kind of transport |
|
||||
| `Bye { reason }` | graceful goodbye; not a revocation of anything |
|
||||
|
||||
The final field of an authenticated announcement is an optional Tsunagi software
|
||||
version. It is a display hint for the current session. Control v8 readers that
|
||||
The capabilities in an authenticated announcement may be followed by a Tsunagi
|
||||
software version. It is a display hint for the current session. Control v8 readers that
|
||||
predate the field stop decoding after the capabilities. Updated readers accept a
|
||||
frame ending there and show the version as unknown. A present label is limited
|
||||
to 64 ASCII letters, digits, dots, plus signs and hyphens. An invalid hint is
|
||||
ignored. Authentication, identity derivation and transport selection use their
|
||||
own wire versions independently of this label.
|
||||
|
||||
The next optional field, `uses_your_exit`, tells the recipient whether the sender
|
||||
selected it as the exit for this network. It is sent directly to the affected peer
|
||||
when the selection changes, including while idle. The hint only affects the
|
||||
display and expires with the authenticated session. For peers that omit it, an
|
||||
exit lists the peer for one minute after its last delivered forwarding packet.
|
||||
|
||||
`broadcast` is a per-network local opt-in, enabled by default and treated as
|
||||
false until an authenticated announcement arrives. It governs IP broadcast
|
||||
fanout and local admission; encrypted transit still uses the existing envelope.
|
||||
|
||||
+4
-3
@@ -217,9 +217,10 @@ kernel test `serving_an_established_flow_while_switching_the_local_exit` uses
|
||||
network namespaces and keeps a real TCP connection open across both switches.
|
||||
On disposable macOS and Windows runners the native subnet workflow checks the
|
||||
same-destination split on two utuns or two Wintun adapters. Its macOS test
|
||||
requires IPv4 forwarding enabled. Windows userspace forwarding also has
|
||||
ordinary loopback tests for TCP resets, half-closes, UDP port stability and
|
||||
connection limits.
|
||||
starts with IPv4 forwarding disabled and verifies the offer enables it. The
|
||||
workflow restores the original value. Userspace exits have loopback tests for
|
||||
TCP resets, half-closes, UDP port stability and connection limits. The macOS
|
||||
test sends ICMP echo through an unprivileged socket bound to loopback.
|
||||
|
||||
Linux exit-client unit tests cover preservation of foreign mark bits, matching
|
||||
only the agent's UID and locally owned TCP/UDP sockets, exact tagged cleanup,
|
||||
|
||||
Reference in new issue
Block a user