• Add ephemeral pairwise Amnezia transport and runtime fallback

    ab released this 2026-10-11 12:52:10 +00:00 | 11 commits to master since this release

    Plain WG and QUIC can be blocked or severely degraded while the iroh control
    connection still works. Add an awg carrier with one independent UDP socket,
    WireGuard engine and randomized masking profile per network/peer attempt.
    The smaller endpoint id negotiates fresh outer keys, PSK, header protection,
    header ranges, padding and signature templates through private authenticated
    control messages. Restart or fallback reentry generates a new profile;
    ordinary rekeying preserves the current profile. No pair parameters enter
    signed state, capabilities, persistent storage or public message events.
    Private payloads and serialized control buffers redact and zeroize themselves.

    Adapt the bounded packet masking engine from RunaRoo/AmneziaWG-RS at commit
    51579a7d6e8882d1d8d6d00822f09e18a9423b73, retaining its Apache license and
    provenance. Declare WTFPL AND Apache-2.0 in package metadata to cover both
    new glue and the adapted source. Reuse boringtun instead of upstream's Node/global executors and
    interface machinery. This is Tsunagi AWG wire version 1, with standard WG
    headers restored before authentication; external Amnezia server compatibility
    is not implemented. DNS/SIP signature generators vary fields instead of
    replaying captures. Each attempt closes independently, bounds allocation,
    queues, candidates and fragment assemblies, and supports the full 64 KiB
    carrier contract using UDP packets at most 1200 bytes. Yield between fragment
    batches so large messages do not starve local socket readers.

    Keep carrier encryption separate from end-to-end tunnels so multihop relays
    still forward opaque ciphertext. The system owns the sole interface, signed
    addresses and admission. Plugins receive neither network secrets nor paths.
    Expose a bounded opaque control sender at the transport boundary; core control
    messages remain outside protocol crates. Optional STUN on the pair's actual
    socket adds IPv4 public candidates in CLI direct/relay mode, with a finite
    query deadline and an off/alternate-server option. Local mode remains offline.
    Symmetric NAT, IPv6-only paths and arbitrary UDP blocking can still require
    fallback; no AWG-over-QUIC or hidden AWG relay is introduced.

    Default carrier order is wg, awg, wg-quic, tcp-tls. Advance the fallback cycle
    after setup failures and sustained runtime loss, even after earlier cooldowns
    expire. Authenticated delivery probes traverse the actual encrypted tunnel,
    fit the interface MTU and never enter the TUN. Retire after a 20-second warmup
    and at least 60% loss over at least 15 completed recent observations. Preserve
    logical tunnels and control sessions while explicitly closing physical links,
    including TCP reader/writer tasks. Retain the newest private probe settings
    across independently queued control negotiation and inbound installation.
    CLI/tray reports keep end-to-end protocol and actual carrier separate.

    Control ALPN/version becomes tsunagi/ctrl/6 for the new private message;
    upgrade all members together. Data ALPN/envelopes remain version 5. Network
    identity derivation, transcript encoding, device identities, signed records,
    saved network configuration and release versions are unchanged.

    Validation on Linux through nix develop:

    • cargo fmt --all -- --check
    • cargo clippy --locked --workspace --all-targets -- -D warnings
    • cargo test --locked --workspace --all-targets, with the inherited
      TSUNAGI_CONTROL_SOCKET override removed: 504 passed, 2 pre-existing ignored

    Tests use real iroh membership, SQLite, UDP sockets and WireGuard encryption
    with memory TUNs. Cover three independent pairs, full-size IP and carrier
    frames, restart freshness/socket release, 80% carrier datagram loss, fallback
    to real iroh, fresh retries with working delivery checks, unequal small MTUs,
    malformed negotiations/profiles, role and resource bounds, probe forgery and
    STUN parsing. Earlier compile/lint iterations and focused tests caught RNG
    API/initializer mistakes, a retry assertion racing path installation, and a
    large-fragment burst overflowing loopback buffers; corrected before these
    successful checks. Normalized upstream license line endings for diff checks.
    Public NAT/STUN connectivity, actual DPI effectiveness, WAN performance,
    per-pair memory measurement, macOS/Windows, privileged TUN operations and
    manual tray interaction were not exercised.

    Downloads