From dea21fa9aa1c24c91be0516e212229f65fc90aeb Mon Sep 17 00:00:00 2001 From: Jan-Erik Rediger Date: Sun, 12 Mar 2023 19:36:42 +0100 Subject: [PATCH] Renamed and readme docs --- Cargo.lock | 24 +++++++++++----------- Cargo.toml | 2 +- README.md | 40 ++++++++++++++++++++++++++---------- rust/examples/echo_client.rs | 2 +- rust/examples/echo_server.rs | 2 +- rust/src/lib.rs | 10 ++++----- 6 files changed, 49 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a1820ff..07540ef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -216,18 +216,6 @@ version = "0.2.140" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" -[[package]] -name = "libtailscale" -version = "0.1.0" -dependencies = [ - "env_logger", - "hyper", - "log", - "nix", - "thiserror", - "tokio", -] - [[package]] name = "linux-raw-sys" version = "0.1.4" @@ -453,6 +441,18 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" +[[package]] +name = "tsnet" +version = "0.1.0" +dependencies = [ + "env_logger", + "hyper", + "log", + "nix", + "thiserror", + "tokio", +] + [[package]] name = "unicode-ident" version = "1.0.8" diff --git a/Cargo.toml b/Cargo.toml index 09135e2..2e3e7da 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "libtailscale" +name = "tsnet" version = "0.1.0" edition = "2021" license = "BSD-3-Clause" diff --git a/README.md b/README.md index dca88f2..3a4a24f 100644 --- a/README.md +++ b/README.md @@ -1,32 +1,50 @@ -# libtailscale +# tsnet - bindings for libtailscale. libtailscale is a C library that embeds Tailscale into a process. +tsnet is a Rust crate wrapping libtailscale and exposing a Rust-y API on top. Use this library to compile Tailscale into your program and get an IP address on a tailnet, entirely from userspace. -## Building +## Requirements -With the latest version of Go, run: +* Rust compiler & Cargo +* Go v1.20 or higher -``` -go build -buildmode=c-archive +## Getting started + +After running `cargo init` add the following lines to your `Cargo.toml` file: + +```toml +tsnet = "0.1.0" ``` -This will produce a `libtailscale.a` file. Link it into your binary, -and use the `tailscale.h` header to reference it. +## Development -It is also possible to build a shared library using +Build with ``` -go build -buildmode=c-shared +cargo build +``` + +Run tests with + +``` +cargo test +``` + +Run the examples with + +``` +cargo run --example echo_server +cargo run --example echo_client ``` ## Bugs Please file any issues about this code or the hosted service on -[the issue tracker](https://github.com/tailscale/tailscale/issues). +[the issue tracker](https://github.com/badboy/tailscale/issues). ## License -BSD 3-Clause for this repository, see LICENSE. \ No newline at end of file +BSD 3-Clause for this repository, see LICENSE. diff --git a/rust/examples/echo_client.rs b/rust/examples/echo_client.rs index fcced88..288245c 100644 --- a/rust/examples/echo_client.rs +++ b/rust/examples/echo_client.rs @@ -1,6 +1,6 @@ use std::{env, io::Write}; -use libtailscale::{ServerBuilder, Network}; +use tsnet::{ServerBuilder, Network}; fn main() { let target = env::args() diff --git a/rust/examples/echo_server.rs b/rust/examples/echo_server.rs index 9058c43..773b892 100644 --- a/rust/examples/echo_server.rs +++ b/rust/examples/echo_server.rs @@ -4,7 +4,7 @@ use std::{ thread, }; -use libtailscale::{ServerBuilder, Network}; +use tsnet::{ServerBuilder, Network}; fn main() { env_logger::init(); diff --git a/rust/src/lib.rs b/rust/src/lib.rs index ae218ca..797ac17 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -13,7 +13,7 @@ //! //! ```rust,no_run //! use std::net::TcpStream; -//! use libtailscale::{ServerBuilder, Network}; +//! use tsnet::{ServerBuilder, Network}; //! //! fn main() { //! let ts = ServerBuilder::new().ephemeral().redirect_log().build().unwrap(); @@ -37,7 +37,7 @@ //! ```rust,no_run //! use std::{env, io::Write}; //! -//! use libtailscale::{ServerBuilder, Network}; +//! use tsnet::{ServerBuilder, Network}; //! //! fn main() { //! let srv = ServerBuilder::new() @@ -124,7 +124,7 @@ impl Display for Network { /// ## Example /// /// ```rust,no_run -/// use libtailscale::{ServerBuilder, Network}; +/// use tsnet::{ServerBuilder, Network}; /// /// let server = ServerBuilder::new().ephemeral().build().unwrap(); /// let ln = server.listen(Network::Tcp, ":1999").unwrap(); @@ -222,7 +222,7 @@ impl Drop for Server { /// ## Example /// /// ```rust,no_run -/// use libtailscale::ServerBuilder; +/// use tsnet::ServerBuilder; /// /// let server = ServerBuilder::new().ephemeral().build().unwrap(); /// ``` @@ -401,7 +401,7 @@ impl ServerBuilder { /// /// ```rust,no_run /// use std::net::TcpStream; -/// use libtailscale::{ServerBuilder, Network, Result}; +/// use tsnet::{ServerBuilder, Network, Result}; /// /// fn handle_client(stream: TcpStream) { /// // ...