Add pure WireGuard direct UDP data plane plugin and transport

Peers communicating on uncensored networks can benefit from raw WireGuard
performance over direct UDP without QUIC framing or double-encryption
overhead. This provides Tailscale-like direct tunnel performance while
preserving Tsunagi's decentralized mesh architecture.

Key changes:
- Create `tsunagi-wireguard` crate implementing the `IpPlugin` and
  `PacketTransport` contracts:
  - `WG_PROTOCOL = "wg"` with wire version 1.
  - Bounded `WgAnnouncement` carrying WireGuard public keys, listening UDP
    ports, and candidate IP addresses (filtering out overlay interfaces).
  - `WgKeyStore` managing persistent per-network WireGuard X25519 keys
    in SQLite with zeroization on drop.
  - `WireguardTransport` providing direct UDP packet transmission, candidate
    address tracking, inbound link delivery, and roaming support.
  - `WireguardDevice` running userspace WireGuard encryption via `boringtun`,
    timer maintenance, and AllowedIPs source enforcement.
- Integrate `wg` into `tsunagi-cli`:
  - Set default protocols to `"wg,tcp-tls,wg-quic"` so all protocols are
    enabled by default in order of throughput and performance.
  - Support `"wireguard"` as a convenience alias for `"wg"` in `--protocol`.
  - Bind `PureWgTransport` and launch the inbound datagram accept loop on `up`.
  - Pass `pure_wg` plugin to `AgentControl` and update `build_report` so
    active WireGuard tunnels and overlay metrics are reported in `tsunagi status`.
  - Clean up WireGuard keys on network removal in `forget_protocol_state`.
- Comprehensive test coverage in `tsunagi-wireguard`:
  - `announcement_tests`: round-trip serialization and verification of malformed,
    mismatched network, zero port, or self-claiming announcements.
  - `transport_tests`: loopback UDP link delivery between transports.
  - `plugin_tests`: end-to-end two-peer handshake and bidirectional IP packet
    transit over direct UDP.

Validation on Linux:
- cargo fmt --all -- --check passed.
- cargo clippy --locked --workspace --all-targets -- -D warnings passed.
- cargo test --locked --workspace --all-targets passed.
This commit is contained in:
Aleksandr Bogomiakov committed 2026-10-01 01:24:25 +01:00
1 parent 46575d0899
commit 7070a16104
14 files changed
+2906 -90

No files matched your search

Generated
+25
View File
@@ -4253,6 +4253,7 @@ dependencies = [
"tsunagi",
"tsunagi-tcp-tls",
"tsunagi-wg-quic",
"tsunagi-wireguard",
]
[[package]]
@@ -4309,6 +4310,30 @@ dependencies = [
"zeroize",
]
[[package]]
name = "tsunagi-wireguard"
version = "0.1.0"
dependencies = [
"boringtun",
"bytes",
"data-encoding",
"hex",
"iroh",
"netdev 0.46.3",
"postcard",
"rand 0.10.3",
"rusqlite",
"serde",
"subtle",
"tempfile",
"thiserror 2.0.20",
"tokio",
"tracing",
"tracing-subscriber",
"tsunagi",
"zeroize",
]
[[package]]
name = "tun"
version = "0.8.14"