mix-tunnel
@nymproject/mix-tunnel (opens in a new tab) owns a single mixnet tunnel in the browser and exposes it to the feature packages built on it: mix-fetch, mix-dns, and mix-websocket. All three call into the same tunnel, so they share one IPR connection, one userspace TCP/IP stack (smoltcp (opens in a new tab)), and one DNS cache.
The tunnel lives in a Web Worker and is built on smolmix-wasm (opens in a new tab), the WebAssembly build of the Rust smolmix crate. One WASM instance per page, regardless of how many feature packages you import. See mix-* architecture for how the worker, the Comlink boundary, and the smoltcp + rustls stack fit together.
When to use it directly
Most apps don't import mix-tunnel directly. The feature packages re-export setupMixTunnel, disconnectMixTunnel, and getTunnelState, so calling setupMixTunnel() from mix-fetch brings the tunnel up for all three.
Use mix-tunnel directly when you want to:
- Configure the tunnel once at app startup, before any feature package is loaded.
- Inspect tunnel state from UI code that isn't tied to a specific feature package.
- Tear down the tunnel explicitly, for example before a page unload.
In this section
- Get started: install and bring the tunnel up.
- Reference: configuration and reading tunnel state.
- Architecture: how the shared tunnel and Web Worker are wired.
- Exit security: what the IPR exit can see.
- TypeDoc reference: generated from the source.
- Examples (opens in a new tab): the mix-fetch, mix-dns, and mix-websocket example apps all bring the tunnel up through this package.