Group data transports and add reverse TCP dialing and Shoes carriers

Let the elected opener invite its authenticated peer to dial back after
a forward TCP attempt fails. Limit the reverse attempt, correlate failure
replies with the active generation and cancel it on membership or policy
changes. Only mutually enabled carriers with link-reverse v1 participate.
Keep native TCP/TLS wire v2 and use the advertised TCP port with direct
control-path or configured bootstrap IPs. Race candidate connects, bound
handshakes, verify the Ed25519 SPKI and wake every link-close waiter.

Add two separately versioned embedded Shoes profiles. VLESS runs over
XHTTP stream-one with HTTP/2 and pinned TLS 1.3. Shadowsocks 2022 selects
AES-128-GCM or AES-256-GCM per connection. Allocate a new credential and
request path or salt for each attempt and admit it once through private
mesh control. Both profiles terminate a local mesh service and retain the
existing inner WireGuard tunnel. Attribute the adapted Shoes v0.3.8 wire
code and keep its MIT license. Preferred ports are 9443 and 9444.

Expose WireGuard, iroh, Native and Shoes as collapsible groups in the
desktop and Android transport editor. A partial group's checkbox enables
all its children. Keep the global protocol priority, save the concrete
list per network and preserve explicitly saved choices including none.
New networks enable all six carriers. Keep the existing CLI protocol
names and unqualified port behavior. Advance local IPC to v30 for the
catalog labels and groups. The existing network identity and encrypted
data formats for the four original protocols stay compatible.

Checked formatting, strict workspace Clippy and the full macOS workspace
test suite (684 passed, 8 opted out by default). The initial sandbox
denied loopback sockets. A full run also exposed an overly broad control
dispatch check in the existing standalone AWG test; restoring the
transport contract fixed it. Ran the opt-in upstream Shoes 0.3.8 reference
test on loopback for HTTP/2 and both Shadowsocks methods. Checked Android
arm64 and Windows GNU targets by cross-compilation. No live DPI or
physical-device network measurements were performed.
This commit is contained in:
Aleksandr Bogomiakov committed 2026-11-26 14:39:11 +02:00
1 parent 68f19d1758
commit 16d7f82af5
42 files changed
+2695 -392

No files matched your search

+3 -3
View File
@@ -1,11 +1,11 @@
# Pairwise Amnezia transport
The CLI's default carrier preference is `wg,awg,wg-quic,tcp-tls`. To select
The CLI's default carrier preference is `wg,awg,wg-quic,tcp-tls,vless-xhttp,ss2022`. To select
AWG explicitly:
```sh
tsng up --protocol awg
tsng up --protocol wg,awg,wg-quic,tcp-tls
tsng up --protocol wg,awg,wg-quic,tcp-tls,vless-xhttp,ss2022
```
The startup list is the initial per-network preference. A saved network choice
@@ -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 v29,
carrier comparisons are optional on the mesh wire. Local IPC is v30,
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
+3
View File
@@ -76,6 +76,9 @@ And in crates of their own:
|---|---|
| `tsunagi-wireguard` | independent ordinary WG and masked UDP hop engines, private pair negotiation and local candidates |
| `tsunagi-tcp-tls` | TLS hop encryption and bounded reachability announcements; no inner IP cipher |
| `tsunagi-shoes` | ephemeral credentials negotiated privately for each TCP attempt |
| `tsunagi-vless-xhttp` | VLESS over XHTTP stream-one, HTTP/2 and TLS 1.3 |
| `tsunagi-ss2022` | Shadowsocks 2022 TCP wire profile and authenticated records |
| `tsunagi-awg` | ephemeral pairwise Amnezia masking, private negotiation and independently encrypted UDP carriers; shares the independent UDP hop engine with `wg` |
| `tsunagi-wg-quic` | the single internal WireGuard cipher, keys and opaque announcement (historical crate name) |
| `tsunagi` | the command line agent, built as the `tsng` executable: the only place that owns a runtime, a logger and signals |
+46
View File
@@ -0,0 +1,46 @@
# Embedded Shoes transports
Both profiles carry the usual length-prefixed, encrypted mesh datagrams over a
direct TCP stream. Each listener has a preferred port, 9443 for `vless-xhttp`
and 9444 for `ss2022`. If a default is occupied, the agent announces an
available port. An explicitly configured port must bind successfully.
The wire implementations adapt the stream-one request format, HTTP/2 stream
flow control, VLESS TCP handshake and Shadowsocks TCP record format from
[Shoes v0.3.8](https://github.com/cfal/shoes/tree/7680938b96a245a21d9e481ad009205b956e4436).
The protocol crates include the upstream MIT license. Both run inside the agent.
For each new TCP handshake the dialler generates an independent 32-byte
identifier, 32 bytes of secret material and a method selector. It sends the offer
to the destination member on the encrypted control connection for that network.
The receiver acknowledges the identifier before data authentication starts.
Only the two peers see the offer. The receiver accepts one successful claim
within 12 seconds. A replacement, a disabled transport or the end of membership
invalidates pending credentials. The TCP ports and device identities are stable
across these attempts. No per-attempt secret enters SQLite or status output.
* **VLESS + XHTTP** uses a single bidirectional HTTP/2 POST with the XHTTP
stream-one path and standard Referer padding. The path and VLESS UUIDv4
change per attempt. TLS 1.3 authenticates the server using the Ed25519 SPKI
of the expected mesh member. The client uses the peer's IP for the request
authority, so this profile can run without a domain, public PKI or ingress.
* **Shadowsocks 2022** selects AES-128-GCM or AES-256-GCM independently of the
key and salt. The TCP request carries a random salt and padding. The receiver
authenticates the fixed and variable headers, the service selector and the
time window. The response authenticates the request salt. The first payload
byte acknowledges the mesh service. Subsequent data uses standard encrypted
length and payload records. [SIP022](https://shadowsocks.org/doc/sip022.html)
The destination encoded inside either protocol is the mesh service selector
`127.0.0.1:1`. Each endpoint terminates that service in memory and hands the
resulting link to the mesh. The inner WireGuard tunnel authenticates the source
and destination of the overlay traffic.
The elected peer tries advertised TCP listeners first. Candidates can include
verified direct control-path IPs and configured bootstrap IPs paired with the
peer's advertised TCP port. Peers that advertise `link-reverse` v1 can request
one reverse attempt after the forward attempt fails. The first successful
direction carries traffic both ways. If both fail the mesh applies its usual
carrier selection and relay routing. Ports forwarded through a router must
reach the announced TCP listener. Network filtering and NAT determine which
paths can actually be established.
+8 -3
View File
@@ -273,10 +273,15 @@ observations, counter resets, recreated listeners and removal of cached
histories. These are headless egui checks, not native desktop screenshots.
`tsunagi-wg-quic/tests/carriers.rs` uses the same internal WireGuard plugin over
real ordinary WG UDP and TCP/TLS, with loopback address selection and memory
TUNs. Exact original IP byte/packet counts exclude health probes and encryption
real ordinary WG UDP, native TCP/TLS, VLESS/XHTTP and Shadowsocks 2022 with
loopback address selection and memory TUNs. For each TCP carrier a second test
removes every candidate in the elected direction and exchanges IP packets in
both directions over the reverse socket. Exact original IP byte/packet counts exclude health probes and encryption
overhead. An artificial delay on a real TCP/TLS link exercises automatic
selection of a faster QUIC carrier. Both endpoints exchange packets across the
selection of a faster QUIC carrier. An optional reference test runs the upstream
Shoes v0.3.8 executable against the embedded VLESS/XHTTP client and both
Shadowsocks methods. Set `TSUNAGI_SHOES_BIN` and run
`cargo test --locked -p tsunagi-runtime --test shoes_reference -- --ignored`. Both endpoints exchange packets across the
transition and retain their original encrypted tunnels. The AWG suite connects
AWG-only and QUIC-only endpoints through a
mixed relay. One real smoltcp TCP connection stays established through relay →
+2 -1
View File
@@ -47,7 +47,8 @@ peer by the agent and runs a WireGuard tunnel over it:
```
Reachability belongs to external carriers: ordinary WireGuard UDP (`wg`),
Amnezia-masked UDP (`awg`), iroh QUIC (`wg-quic`), or TCP/TLS (`tcp-tls`). The
Amnezia-masked UDP (`awg`), iroh QUIC (`wg-quic`), TCP/TLS (`tcp-tls`),
VLESS/XHTTP (`vless-xhttp`) or Shadowsocks 2022 (`ss2022`). The
user's ordered choice applies only to those physical data links. The internal
capability `wireguard-e2e` v4 is fixed and hidden from the CLI/tray controls.
All carriers move the same inner encrypted bytes, including through relays.