Skip to main content

Crate tunnet

Crate tunnet 

Source
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 sync
  • direct — re-exports for Direct / local-first mode types
  • send — file transfer APIs
  • serve — mesh reverse-proxy (serve) APIs

Modules§

policy

Structs§

EndpointSnapshot
EnrollConfig
Configuration for enrollment (enroll when the managed feature is enabled).
EnrollResult
Result of a successful enrollment.
NetworkMembershipSnapshot
Peer
A peer currently known to the local overlay.
PeerEntry
PolicyBundle
StreamHeader
Header carried on every mesh application stream.
StreamListener
Accepts inbound application streams from mesh peers.
TunnetNode
A handle to the local overlay.
TunnetNodeBuilder
Builder for TunnetNode.
TunnetStream
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_dir so subsequent crate::TunnetNode::builder .start() calls can bootstrap without a token.

Type Aliases§

Result
Result alias for the Tunnet SDK.