Expand description
Compile Tailscale into your program and get an entirely userspace IP address on a tailnet.
From here you can listen for other programs on your tailnet dialing you, or connect directly to other services.
Based on libtailscale, the C wrapper around the
Tailscale Go package.
See https://pkg.go.dev/tailscale.com/tsnet for Go module docs.
Examples
Server
use std::net::TcpStream;
use tsnet::{ServerBuilder, Network};
fn main() {
let ts = ServerBuilder::new().ephemeral().redirect_log().build().unwrap();
let ln = ts.listen(Network::Tcp, ":1999").unwrap();
for conn in ln {
match conn {
Ok(conn) => handle_client(conn),
Err(err) => panic!("{err}"),
}
}
}
fn handle_client(mut stream: TcpStream) {
// ...
}Client
use std::{env, io::Write};
use tsnet::{ServerBuilder, Network};
fn main() {
let srv = ServerBuilder::new()
.ephemeral()
.build()
.unwrap();
let mut conn = srv.connect(Network::Tcp, "echo-server:1999").unwrap();
write!(conn, "This is a test of the Tailscale connection service.\n").unwrap();
}Structs
- A server, listening for connections.
- A Tailscale node.
- Server factory, which can be used to configure the properties of a new server.
Enums
- Possible errors
- The possible network types.
Type Aliases
- A Result, returning either a value or an error, defaulting to the crate error.