Files
tsunagi/README.md
T
Aleksandr Bogomiakov d941cdac7a Change network protocol selections at runtime
Protocol selection previously belonged to tsng up and therefore to the
service command line. A blocked or degraded carrier could only be removed
by editing the service and restarting the whole agent. Make the ordered
selection a local per-network setting instead.

Add Agent::set_protocols and a local control request shared by CLI and tray.
Keep tsng protocols without arguments as the protocol catalog; naming a
network shows its selection and supplying a comma-separated list replaces
it. Accept exact names, full ids and unique prefixes using shared selector
rules; ambiguous selectors and invalid lists change nothing. An explicit
none selects control-only operation. Offline edits take the directory lock
and apply on the next start; live edits never write behind the daemon.

Register every built-in plugin and transport in the CLI. Treat up --protocol
as ordered initial defaults for networks without an override, allowing a
protocol absent from the unit to be enabled later. Retain the targeting of
unqualified startup options and allow explicitly scoped options to configure
initially disabled protocols. Persist NULL for inherited preferences and an
empty selection distinctly in SQLite schema 8; migration preserves existing
identities, secrets, signed records and counters.

Serialize changes with network lifecycle operations and commit preferences
before applying or announcing them. Retire only the affected network's data
links and E2E channels, cancel pending opens, and reject obsolete completion
results by attempt id. Clear peer data channels when authenticated protocol
capabilities change while retaining control sessions and topology. Replay
allocations and peer identities after asynchronously prepared plugins become
ready. A control-only start defers creation of the agent's single interface
until data is enabled; plugins receive a sink that can use it later. Automatic
carrier fallback continues to preserve E2E state; explicit policy changes
renegotiate it. Identity derivation and peer wire formats are unchanged.

Add a collapsible protocols row to each tray network tile, with a catalog
provided by the daemon, descriptions, immediately applied checkboxes and
preference-order buttons. Keep editing disabled until the worker refreshes
status so a second click cannot overwrite an edit using a stale snapshot.
Local IPC wire version is 20 for the new request and report fields; upgrade
and restart agent, CLI and tray together. Crate release versions remain unchanged; the requested RC tag is v0.1.0-rc.30.

Validation on Linux through nix develop:
- cargo fmt --all -- --check
- cargo clippy --locked --workspace --all-targets -- -D warnings
- cargo test --locked --workspace --all-targets: 509 passed, 2 existing ignored
  tests, with inherited TSUNAGI_CONTROL_SOCKET and TSUNAGI_CONTROL_GROUP removed

Tests use real iroh membership, SQLite, UDP, AWG and WireGuard encryption,
QUIC carriers and memory TUNs. Cover either endpoint-id role, full-size packet
delivery after switching, an unaffected second active network, saved selection
after restart, empty/invalid selections, first enablement without restart,
rapid changes racing old opens, live and offline CLI changes, startup-absent
protocols and preservation of signed state through migration. Earlier compile
and focused-test iterations caught initializer mistakes, a short test secret,
asynchronous plugin allocation readiness, and an inherited system socket
path; corrected before the successful final checks. Plain cargo was unavailable
in the host shell, so validation used the Nix toolchain. Manual tray interaction,
macOS/Windows, privileged host TUNs and public-network traversal were not run.
2026-10-12 16:19:18 +01:00

10 KiB
Raw Permalink Blame History

tsunagi

A mesh VPN with no server.
Pick a network name, share a secret, and your machines are on one private network.

release CI license

laptop$ tsng join -n home
joined `home`
  secret  tsn1u7c…

server$ tsng join -n home -s tsn1u7c…
server$ tsng id hostname server

laptop$ ssh server.home

No account, no coordination server, no admin console, no keys to approve. Anyone who knows the name and the secret is in. Nobody else can find the network, let alone enter it.

Why

Tailscale, Headscale and ZeroTier are great, but each needs a control server: theirs, or one you have to run and keep alive. tsunagi doesn't. Machines find each other through the public BitTorrent DHT, connect directly (hole punching, with relay fallback), and keep the network state among themselves.

Tailscale Headscale ZeroTier tsunagi
Control server hosted by vendor you run it hosted or self-run none
Account / sign-in yes yes yes no
To join a network sign in, get approved pre-auth key network ID, approval name + secret
Direct connections yes yes yes yes
Exit nodes yes yes via routes yes

Features

  • Two things to know: a network name and a secret. A secret is generated for you when you make a network.
  • Direct, encrypted links between members (WireGuard cryptography), with relay fallback behind strict NATs.
  • Names for machines: server.home just works, even while server is switched off. A name belongs to whoever claimed it first; a later device with the same name keeps working by address and is told so.
  • Exit nodes: send all your internet traffic through any member that offers one.
  • Multi-hop: members that can't reach each other directly are routed through a member that can, over whatever kind of link each hop has. A member reached that way is online, and shown as relayed; traffic moves to a direct link by itself the moment one comes up.
  • LAN games: UDP broadcasts are relayed, so "LAN" lobbies show up across the mesh.
  • Several networks at once on one device.
  • Tray app for Windows, macOS and Linux; a command line for everything.

Install

Grab a build from the latest release.

Platform How
Windows Run tsunagi-setup-<version>-x86_64.exe. Installs the service, the tray and tsng.
macOS brew tap house-of-vanity/tap && brew install --cask tsunagi-gui
CLI only: brew install tsunagi
Debian / Ubuntu sudo apt install ./tsunagi-gui_<version>_amd64.deb (tsunagi_… for no tray)
Arch sudo pacman -U tsunagi-gui-<version>-1-x86_64.pkg.tar.zst
NixOS Flake and module below
Any other Linux Unpack the tarball, then sudo ./install.sh && sudo systemctl enable --now tsunagi

Linux packages run the agent as an unprivileged service user. Add yourself to the tsunagi group (sudo usermod -aG tsunagi $USER, then log in again) to use tsng and the tray without sudo.

Quick start

tsng join -n home                 # first machine: makes the network and prints a secret
tsng join -n home -s tsn1…        # every other machine
tsng status                       # who is online, over which path

Every new network gets a stable pseudorandom /24 in 10.0.0.0/8, derived from its network id. Its members agree on that range even when starting offline, and each gets a name like <host>.home. Existing signed ranges are preserved.

If two configured networks have overlapping ranges, the agent runs only one. tsng status, tsng network and the tray show which network blocks the other. tsng network start <name-or-id> or the tray’s “Switch to this network” button suspends the conflicting networks. They resume automatically when the selected network stops; the selection survives restarting the agent. Explicitly stopping a suspended network cancels its automatic resume.

Machines are called tsunagi-<id> until you rename them: tsng id hostname laptop.

Exit nodes

tsng network exit-node home on    # on the machine that should be the exit
tsng exit-node                    # on another one: who offers an exit
tsng exit-node laptop             # send everything through it
tsng exit-node off

The tray does the same with a checkbox. An exit node sees everything you send through it, so use only members you trust. Details and per-OS notes.

The default data transport order is wg,awg,wg-quic,tcp-tls. AWG negotiates a fresh masking profile and outer keys for each pair connection attempt, including reentry after fallback. Sustained data loss triggers switching independently of the iroh control connection. Configuration and limits.

Change a network's protocol selection without editing its service or restarting:

tsng protocols                         # available protocols and settings
tsng protocols home                    # this device's choice for home
tsng protocols home awg,wg-quic         # prefer AWG, retain QUIC as fallback
tsng protocols home none                # control plane only

Exact network names, full ids and unique id prefixes work here. The choice is local to this device, saved per network and applied immediately; an offline change applies on the next start. In the tray, expand protocols on a network tile to toggle protocols or change their preference order. Both endpoints need a common protocol at the same wire version. tsng up --protocol supplies the initial defaults for networks without a saved choice; it does not restrict which built-in protocols can be enabled later.

Platforms

Platform Build CLI tsng Tray Exit node: offer / use Packages
Linux x86_64 release ✔ ✔ ✔ / ✔ .deb, .pkg.tar.zst, tarball, Nix
Linux aarch64 release ✔ –¹ ✔ / ✔ .deb, .pkg.tar.zst, tarball, Nix
Linux armv7 release ✔ –¹ ✔ / ✔ .deb, .pkg.tar.zst, tarball
macOS, Apple silicon release ✔ ✔ ✔ / ✔² Homebrew, tarball
macOS, Intel from source ✔³ ✔³ ✔ / ✔²³ –
Windows x86_64 release ✔ ✔ ✔ / ✔² installer, zip

¹ Not in the release; builds from source (and through Nix). ² Newer and less battle-tested than on Linux. ³ Builds from source, not covered by CI.

The Linux CLI is a single static binary: it runs on any distribution.

NixOS

The repository is a flake with a package and a module.

# flake.nix
{
  inputs.tsunagi.url = "github:house-of-vanity/tsunagi";

  outputs = { nixpkgs, tsunagi, ... }: {
    nixosConfigurations.myhost = nixpkgs.lib.nixosSystem {
      modules = [
        tsunagi.nixosModules.default
        {
          services.tsunagi = {
            enable = true;
            tray.enable = true;      # optional, for desktops
            users = [ "alice" ];     # may use tsng and the tray without sudo
          };
        }
      ];
    };
  };
}

Just trying it: nix run github:house-of-vanity/tsunagi#tsunagi-cli -- --help. packages.<system>.tsunagi (with the tray) and tsunagi-cli are also exported, along with overlays.default.

Build from source

Rust 1.91 or newer.

cargo build --release --bin tsng               # the agent and CLI
cargo build --release --bin tsunagi-tray       # the tray (Linux needs GTK 3 and libayatana-appindicator)

Windows needs Wintun next to tsng.exe. Per-platform notes: Linux, Arch, macOS, Windows.

How it works

  • Your name and secret derive a network identity. Members publish signed contact records to the public Mainline DHT under it, and find each other there.
  • Every connection proves knowledge of the secret before it's accepted. Traffic between members is end-to-end encrypted, relays included.
  • Addresses and names are claimed with each device's own key and replicated between members. There is no one in charge, so nothing to be taken down.

The secret is the only key, so make it a good one (the generated ones are). The threat model says what this does and doesn't protect against.

Documentation

Architecture · Protocol · WireGuard data plane · Pairwise Amnezia transport · Routing · Exit nodes · Threat model · Contributing

Licence

WTFPL: do what the fuck you want to.