Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ point. More detailed usage instructions and technical details can be found in ea
```mermaid
block-beta
columns 4

API["API/Language Bindings"]:4
RT["Runtime"]:4
CP["Control Plane"]:1
Expand Down Expand Up @@ -59,7 +59,7 @@ Implements the TCP, UDP, and raw socket abstractions for the overlay network (ta

### Control Plane

Crates that communicate with Tailscale's control plane (or Headscale) and provide configuration for the data plane. The control plane handles authentication/authorization, node registration, policy updates, network map distribution, and much more for the nodes in a tailnet.
Crates that communicate with Tailscale's control plane (or Headscale) and provide configuration for the data plane. The control plane handles authentication/authorization, node registration, policy updates, network map distribution, and much more for the nodes in a tailnet.

- [`ts_control`](ts_control/src/lib.rs): control plane client that handles registration, authorization/authentication, configuration, and streaming updates.
- [`ts_control_noise`](ts_control_noise/src/lib.rs): abstraction that wraps control plane communications in a Noise IK tunnel, transparently handling cryptography for the client.
Expand All @@ -78,7 +78,7 @@ Types and (de)serialization code for control plane traffic "on the wire". `ts_co

Crates that communicate with other Tailscale nodes on the tailnet. The data plane is responsible for actually exchanging packets between peers on the tailnet, including transport management (DERP, TUN, etc.), routing, packet filtering, and tunneling.

- [`ts_dataplane`](ts_dataplane/src/lib.rs): wires all the individual data plane functions together, flowing inbound and outbound packets through the components in the correct order. The various data plane components are described below.
- [`ts_dataplane`](ts_dataplane/src/lib.rs): wires all the individual data plane functions together, flowing inbound and outbound packets through the components in the correct order. The various data plane components are described below.

#### Packet Filtering

Expand All @@ -88,13 +88,13 @@ Crates that communicate with other Tailscale nodes on the tailnet. The data plan

#### Routing

- [`ts_overlay_router`](ts_overlay_router/src/lib.rs): routing table implementation for overlay (tailnet) traffic; determines which peer to send outbound traffic to, and which overlay transport should receive inbound packets.
- [`ts_overlay_router`](ts_overlay_router/src/lib.rs): routing table implementation for overlay (tailnet) traffic; determines which peer to send outbound traffic to, and which overlay transport should receive inbound packets.
- [`ts_underlay_router`](ts_underlay_router/src/lib.rs): routing table implementation for underlay traffic; determines which underlay transport an outbound packet should be sent from, if any.

#### Transports

- [`ts_transport`](ts_transport/src/lib.rs): traits that define transports and how they move traffic in and out of the overlay/underlay network.
- [`ts_transport_derp`](ts_transport_derp/src/lib.rs): an underlay transport that exchanges packets between nodes via Designated Encrypted Relay for Packets (DERP) relay servers.
- [`ts_transport`](ts_transport/src/lib.rs): traits that define transports and how they move traffic in and out of the overlay/underlay network.
- [`ts_derp`](ts_derp/src/lib.rs): an underlay transport that exchanges packets between nodes via Designated Encrypted Relay for Packets (DERP) relay servers.
- [`ts_transport_tun`](ts_transport_tun/src/lib.rs): an overlay transport that exposes a TUN device on the local machine to send/receive packets on the overlay network (tailnet).

#### Tunneling
Expand All @@ -106,9 +106,9 @@ Crates that communicate with other Tailscale nodes on the tailnet. The data plan
Crates used throughout the codebase that provide generic algorithms, data structures, cross-cutting concerns, or development tooling.

#### Algorithms and Data Structures
- [`ts_array256`](ts_array256/src/lib.rs): sparse array of 256 elements with configurable backing store, used with `ts_bart`.
- [`ts_bart`](ts_bart/README.md): BAlanced Routing Table (BART) data structure for fast IP address/prefix search in routing tables and packet filtering.
- [`ts_bitset`](ts_bitset/src/lib.rs): fixed-width bitset used to track presence of elements in `ts_array256`.
- [`ts_array256`](ts_array256/src/lib.rs): sparse array of 256 elements with configurable backing store, used with `ts_bart`.
- [`ts_bart`](ts_bart/README.md): BAlanced Routing Table (BART) data structure for fast IP address/prefix search in routing tables and packet filtering.
- [`ts_bitset`](ts_bitset/src/lib.rs): fixed-width bitset used to track presence of elements in `ts_array256`.
- [`ts_dynbitset`](ts_dynbitset/src/lib.rs): growable bitset built on top of `ts_bitset`, used with `ts_bart_packetfilter`.
- [`ts_keys`](ts_keys/src/lib.rs): data structures representing all of Tailscale's x25519 keys (disco, node, machine, etc.).
- [`ts_packet`](ts_packet/src/lib.rs): base types representing network packets.
Expand All @@ -121,12 +121,12 @@ Crates used throughout the codebase that provide generic algorithms, data struct

#### Examples, Debugging, and Testing
- [`ts_cli_util`](ts_cli_util/src/lib.rs): helpers for writing command line tools and initializing logging, used in examples.
- [`ts_test_util`](ts_test_util/src/lib.rs): common code used by our unit and integration tests, such as determining if the network is available.
- [`ts_test_util`](ts_test_util/src/lib.rs): common code used by our unit and integration tests, such as determining if the network is available.
- [`ts_hexdump`](ts_hexdump/src/lib.rs): traits and functions to generate canonical hexdumps of buffers for debug logging.

#### Protocols
- [`ts_disco_protocol`](ts_disco_protocol/src/lib.rs): incomplete implementation of Tailscale's discovery protocol (disco).
- [`ts_http_util`](ts_http_util/src/lib.rs): HTTP/1 and HTTP/2 client utilities used in `ts_control` and `ts_transport_derp`.
- [`ts_http_util`](ts_http_util/src/lib.rs): HTTP/1 and HTTP/2 client utilities used in `ts_control` and `ts_derp`.
- [`ts_tls_util`](ts_tls_util/src/lib.rs): Transport Layer Sockets (TLS) utilities to manage certificates and establish secure connections over HTTP.

#### Time
Expand Down
77 changes: 38 additions & 39 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ members = [
"ts_control_noise",
"ts_control_serde",
"ts_dataplane",
"ts_derp",
"ts_devtools",
"ts_disco_protocol",
"ts_dynbitset",
Expand All @@ -37,7 +38,6 @@ members = [
"ts_time",
"ts_tls_util",
"ts_transport",
"ts_transport_derp",
"ts_transport_tun",
"ts_underlay_router",
"ts_tunnel",
Expand Down Expand Up @@ -115,6 +115,7 @@ ts_control = { path = "ts_control", version = "0.2.0" }
ts_control_noise = { path = "ts_control_noise", version = "0.2.0" }
ts_control_serde = { path = "ts_control_serde", version = "0.2.0" }
ts_dataplane = { path = "ts_dataplane", version = "0.2.0" }
ts_derp = { path = "ts_derp", version = "0.2.0" }
ts_disco_protocol = { path = "ts_disco_protocol", version = "0.2.0" }
ts_dynbitset = { path = "ts_dynbitset", version = "0.2.0" }
ts_hexdump = { path = "ts_hexdump", version = "0.2.0" }
Expand All @@ -136,7 +137,6 @@ ts_runtime = { path = "ts_runtime", version = "0.2.0" }
ts_test_util = { path = "ts_test_util" }
ts_time = { path = "ts_time", version = "0.2.0" }
ts_transport = { path = "ts_transport", version = "0.2.0" }
ts_transport_derp = { path = "ts_transport_derp", version = "0.2.0" }
ts_transport_tun = { path = "ts_transport_tun", version = "0.2.0" }
ts_underlay_router = { path = "ts_underlay_router", version = "0.2.0" }
ts_tunnel = { path = "ts_tunnel", version = "0.2.0" }
Expand Down
2 changes: 1 addition & 1 deletion ts_cli_util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ rust-version.workspace = true
tailscale.workspace = true
ts_control.workspace = true
ts_netcheck.workspace = true
ts_transport_derp.workspace = true
ts_derp.workspace = true

# Unconditionally required dependencies.
cfg-if.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion ts_cli_util/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use std::sync::Arc;
use futures_util::{Stream, StreamExt};
use tracing::level_filters::LevelFilter;
use tracing_subscriber::{Layer, layer::SubscriberExt, util::SubscriberInitExt};
use ts_derp::{RegionId, ServerConnInfo};
use ts_netcheck::RegionResult;
use ts_transport_derp::{RegionId, ServerConnInfo};

/// Result with a boxed [`core::error::Error`] trait object.
pub type Result<T> = core::result::Result<T, Box<dyn core::error::Error + Send + Sync + 'static>>;
Expand Down
4 changes: 2 additions & 2 deletions ts_control/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ts_packet.workspace = true
ts_packetfilter.workspace = true
ts_packetfilter_state.workspace = true
ts_tls_util.workspace = true
ts_transport_derp.workspace = true
ts_derp.workspace = true

# Unconditionally required dependencies.
bytes.workspace = true
Expand All @@ -51,7 +51,7 @@ default = ["async_tokio"]
async_tokio = ["dep:futures-util", "dep:tokio", "dep:tokio-stream"]

# Allow derp connections to be made without verifying TLS certs. Only for use in tests.
insecure-derp = ["ts_transport_derp/insecure-for-tests"]
insecure-derp = ["ts_derp/insecure-for-tests"]
# Allow control keys to be fetched over plain HTTP1 without TLS. Only for use in tests.
insecure-keyfetch = []

Expand Down
Loading