tailscale-rs

repository·main·Indexed 21 days ago

https://github.com/tailscale/tailscale-rs

A work-in-progress Rust implementation of the Tailscale networking stack. It allows applications to participate in a tailnet by creating TCP/UDP sockets and communicating with peers. The project provides language bindings for C, Elixir, and Python, and includes utility crates such as ts_bart for IP lookups, ts_bart_packetfilter for accelerated packet filtering, and ts_array256 for sparse storage.

Tokens
136K
Snippets
413
Records
576
Agent score
76%

What's inside tailscale-rs

  1. Overview of ts_packetfilter

    main

    The ts_packetfilter package provides functionality for Tailscale packet filters. These filters are used to enforce network policies on a per-tailnet basis.

    Key characteristics:

    • Specification: Filters are defined using the policy file's ACL (Access Control List) and/or grants features.
    • Distribution: Filters are automatically downloaded to each node when it connects to a control server, and are updated whenever the rules or the tailnet configuration changes.
  2. Overview of ts_noise

    main

    ts_noise provides specific Noise protocol implementations required by Tailscale. It is not a general-purpose Noise library; it is strictly limited to two handshake patterns:

    1. Noise IK: Used for the Tailscale control protocol.
    2. Noise IKpsk2: Used for WireGuard.

    The crate's responsibility is limited to the handshake process. Once a handshake concludes and produces a pair of session keys, the caller is responsible for using those keys according to the higher-level protocol requirements.

  3. Overview of ts_http_util

    main

    ts_http_util is a specialized collection of utilities designed for managing HTTP/1.1 and HTTP/2 client connections over either plaintext or TLS streams. It is built using http, hyper, and tokio and is specifically optimized for use within the tailscale ecosystem.

    Note: This crate is tailored for Tailscale's specific requirements and may not be suitable for general-purpose HTTP client needs. For general use cases, it is recommended to use hyper directly, or alternative crates like reqwest or ureq.

  4. Overview of ts_netstack_smoltcp_socket (netsock)

    main

    The ts_netstack_smoltcp_socket (also known as netsock) crate provides an ergonomic sockets API layer built on top of ts_netstack_smoltcp_core.

    It abstracts the low-level Channel command system into a high-level API that mimics standard networking libraries like std::net or tokio::net. It provides familiar types such as UdpSocket, TcpStream, and TcpListener.

    Key architectural details:

    • Internalized Channels: Each socket type internalizes its own Channel, allowing sockets to send commands on their own behalf.
    • Socket Creation: Sockets are created using the CreateSocket trait, which provides extension methods for any type T that implements HasChannel.