Expand description
§tunnet
Embed a Tunnet mesh node inside any Rust application — Tailscale’s tsnet for Rust.
use tunnet::TunnetNode;
use tokio::io::{AsyncReadExt, AsyncWriteExt};
#[tokio::main]
async fn main() -> tunnet::Result<()> {
let node = TunnetNode::builder()
.hostname("my-service")
.state_dir("/var/lib/my-app/tunnet")
.api_key("tnnt_key_...")
.organization_id("org_...")
.network_id("00000000-0000-0000-0000-000000000000")
.control_url("https://cp.tunnet.io")
.management_url("https://api.tunnet.io")
.standalone(true)
.start()
.await?;
let mut stream = node.open_stream("10.0.0.5", 8080).await?;
stream.write_all(b"hello").await?;
let mut buf = [0u8; 64];
let n = stream.read(&mut buf).await?;
println!("got {} bytes", n);
Ok(())
}§Features
managed(default) — control-plane enrollment and syncdirect— re-exports for Direct / local-first mode typessend— file transfer APIsserve— mesh reverse-proxy (serve) APIs
Modules§
Structs§
- Endpoint
Snapshot - Enroll
Config - Configuration for enrollment (
enrollwhen themanagedfeature is enabled). - Enroll
Result - Result of a successful enrollment.
- Network
Membership Snapshot - Peer
- A peer currently known to the local overlay.
- Peer
Entry - Policy
Bundle - Stream
Header - Header carried on every mesh application stream.
- Stream
Listener - Accepts inbound application streams from mesh peers.
- Tunnet
Node - A handle to the local overlay.
- Tunnet
Node Builder - Builder for
TunnetNode. - Tunnet
Stream - A bidirectional byte stream to a mesh peer.
Enums§
- Error
- Errors returned by the Tunnet SDK.
Functions§
- enroll
- One-shot enrollment. Persists identity + state to
state_dirso subsequentcrate::TunnetNode::builder.start()calls can bootstrap without a token.
Type Aliases§
- Result
- Result alias for the Tunnet SDK.