Skip to content

Commit 4e02574

Browse files
committed
ts_transport_derp: rename to ts_derp
The transport implementation is secondary, now in an especially meaningful sense given that transports communicate over PeerIds, while derp uses NodePublicKeys. This rename aligns with separation of the client into the core non-transport functionality, and a transport wrapper that handles translating to and from PeerId (forthcoming in a future commit). Signed-off-by: Nathan Perry <nathan@tailscale.com> Change-Id: If5dd9a39d4e1299fe999f8457e38e94a6a6a6964
1 parent 0a7cfb1 commit 4e02574

52 files changed

Lines changed: 120 additions & 134 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ARCHITECTURE.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ point. More detailed usage instructions and technical details can be found in ea
1919
```mermaid
2020
block-beta
2121
columns 4
22-
22+
2323
API["API/Language Bindings"]:4
2424
RT["Runtime"]:4
2525
CP["Control Plane"]:1
@@ -59,7 +59,7 @@ Implements the TCP, UDP, and raw socket abstractions for the overlay network (ta
5959

6060
### Control Plane
6161

62-
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.
62+
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.
6363

6464
- [`ts_control`](ts_control/src/lib.rs): control plane client that handles registration, authorization/authentication, configuration, and streaming updates.
6565
- [`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.
@@ -78,7 +78,7 @@ Types and (de)serialization code for control plane traffic "on the wire". `ts_co
7878

7979
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.
8080

81-
- [`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.
81+
- [`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.
8282

8383
#### Packet Filtering
8484

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

8989
#### Routing
9090

91-
- [`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.
91+
- [`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.
9292
- [`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.
9393

9494
#### Transports
9595

96-
- [`ts_transport`](ts_transport/src/lib.rs): traits that define transports and how they move traffic in and out of the overlay/underlay network.
97-
- [`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.
96+
- [`ts_transport`](ts_transport/src/lib.rs): traits that define transports and how they move traffic in and out of the overlay/underlay network.
97+
- [`ts_derp`](ts_derp/src/lib.rs): an underlay transport that exchanges packets between nodes via Designated Encrypted Relay for Packets (DERP) relay servers.
9898
- [`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).
9999

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

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

122122
#### Examples, Debugging, and Testing
123123
- [`ts_cli_util`](ts_cli_util/src/lib.rs): helpers for writing command line tools and initializing logging, used in examples.
124-
- [`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.
124+
- [`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.
125125
- [`ts_hexdump`](ts_hexdump/src/lib.rs): traits and functions to generate canonical hexdumps of buffers for debug logging.
126126

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

132132
#### Time

Cargo.lock

Lines changed: 33 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ members = [
1212
"ts_control_noise",
1313
"ts_control_serde",
1414
"ts_dataplane",
15+
"ts_derp",
1516
"ts_devtools",
1617
"ts_disco_protocol",
1718
"ts_dynbitset",
@@ -37,7 +38,6 @@ members = [
3738
"ts_time",
3839
"ts_tls_util",
3940
"ts_transport",
40-
"ts_transport_derp",
4141
"ts_transport_tun",
4242
"ts_underlay_router",
4343
"ts_tunnel",
@@ -115,6 +115,7 @@ ts_control = { path = "ts_control", version = "0.2.0" }
115115
ts_control_noise = { path = "ts_control_noise", version = "0.2.0" }
116116
ts_control_serde = { path = "ts_control_serde", version = "0.2.0" }
117117
ts_dataplane = { path = "ts_dataplane", version = "0.2.0" }
118+
ts_derp = { path = "ts_derp", version = "0.2.0" }
118119
ts_disco_protocol = { path = "ts_disco_protocol", version = "0.2.0" }
119120
ts_dynbitset = { path = "ts_dynbitset", version = "0.2.0" }
120121
ts_hexdump = { path = "ts_hexdump", version = "0.2.0" }
@@ -136,7 +137,6 @@ ts_runtime = { path = "ts_runtime", version = "0.2.0" }
136137
ts_test_util = { path = "ts_test_util" }
137138
ts_time = { path = "ts_time", version = "0.2.0" }
138139
ts_transport = { path = "ts_transport", version = "0.2.0" }
139-
ts_transport_derp = { path = "ts_transport_derp", version = "0.2.0" }
140140
ts_transport_tun = { path = "ts_transport_tun", version = "0.2.0" }
141141
ts_underlay_router = { path = "ts_underlay_router", version = "0.2.0" }
142142
ts_tunnel = { path = "ts_tunnel", version = "0.2.0" }

ts_cli_util/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ rust-version.workspace = true
1616
tailscale.workspace = true
1717
ts_control.workspace = true
1818
ts_netcheck.workspace = true
19-
ts_transport_derp.workspace = true
19+
ts_derp.workspace = true
2020

2121
# Unconditionally required dependencies.
2222
cfg-if.workspace = true

ts_cli_util/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use std::sync::Arc;
55
use futures_util::{Stream, StreamExt};
66
use tracing::level_filters::LevelFilter;
77
use tracing_subscriber::{Layer, layer::SubscriberExt, util::SubscriberInitExt};
8+
use ts_derp::{RegionId, ServerConnInfo};
89
use ts_netcheck::RegionResult;
9-
use ts_transport_derp::{RegionId, ServerConnInfo};
1010

1111
/// Result with a boxed [`core::error::Error`] trait object.
1212
pub type Result<T> = core::result::Result<T, Box<dyn core::error::Error + Send + Sync + 'static>>;

ts_control/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ ts_packet.workspace = true
2424
ts_packetfilter.workspace = true
2525
ts_packetfilter_state.workspace = true
2626
ts_tls_util.workspace = true
27-
ts_transport_derp.workspace = true
27+
ts_derp.workspace = true
2828

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

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

ts_control/src/derp.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
use alloc::collections::BTreeMap;
22

3-
use ts_transport_derp::TlsValidationConfig;
3+
use ts_derp::TlsValidationConfig;
44

5-
/// The full derp state, a map of [`ts_transport_derp::RegionId`]s to [`Region`]s.
6-
pub type Map = BTreeMap<ts_transport_derp::RegionId, Region>;
5+
/// The full derp state, a map of [`ts_derp::RegionId`]s to [`Region`]s.
6+
pub type Map = BTreeMap<ts_derp::RegionId, Region>;
77

8-
/// Convert a derp map from the [`ts_control_serde`] representation to the [`ts_transport_derp`]
8+
/// Convert a derp map from the [`ts_control_serde`] representation to the [`ts_derp`]
99
/// representation.
1010
pub fn convert_derp_map(
1111
derp_map: &ts_control_serde::DerpMap<'_>,
12-
) -> impl Iterator<Item = (ts_transport_derp::RegionId, Region)> {
12+
) -> impl Iterator<Item = (ts_derp::RegionId, Region)> {
1313
derp_map.regions.iter().map(|(id, region)| {
14-
let id = ts_transport_derp::RegionId((*id).into());
14+
let id = ts_derp::RegionId((*id).into());
1515
let region: Region = region.into();
1616

1717
(id, region)
@@ -22,10 +22,10 @@ pub fn convert_derp_map(
2222
#[derive(Debug, Clone, PartialEq, Eq)]
2323
pub struct Region {
2424
/// The info for this region.
25-
pub info: ts_transport_derp::RegionInfo,
25+
pub info: ts_derp::RegionInfo,
2626

2727
/// Servers in this region.
28-
pub servers: Vec<ts_transport_derp::ServerConnInfo>,
28+
pub servers: Vec<ts_derp::ServerConnInfo>,
2929
}
3030

3131
impl From<&ts_control_serde::DerpRegion<'_>> for Region {
@@ -37,15 +37,15 @@ impl From<&ts_control_serde::DerpRegion<'_>> for Region {
3737
}
3838
}
3939

40-
fn region_info(region: &ts_control_serde::DerpRegion) -> ts_transport_derp::RegionInfo {
41-
ts_transport_derp::RegionInfo {
40+
fn region_info(region: &ts_control_serde::DerpRegion) -> ts_derp::RegionInfo {
41+
ts_derp::RegionInfo {
4242
name: region.name.to_string(),
4343
code: region.code.to_string(),
4444
no_measure_no_home: region.no_measure_no_home,
4545
}
4646
}
4747

48-
fn server(server: &ts_control_serde::DerpServer) -> ts_transport_derp::ServerConnInfo {
48+
fn server(server: &ts_control_serde::DerpServer) -> ts_derp::ServerConnInfo {
4949
const DEFAULT_TLS_PORT: u16 = 443;
5050

5151
let https_port = match server.derp_port {
@@ -62,7 +62,7 @@ fn server(server: &ts_control_serde::DerpServer) -> ts_transport_derp::ServerCon
6262
tls_config = TlsValidationConfig::InsecureForTests;
6363
};
6464

65-
ts_transport_derp::ServerConnInfo {
65+
ts_derp::ServerConnInfo {
6666
hostname: server.hostname.to_string(),
6767
https_port,
6868
stun_port: server.stun_port.into(),
@@ -77,13 +77,13 @@ fn server(server: &ts_control_serde::DerpServer) -> ts_transport_derp::ServerCon
7777
}
7878
}
7979

80-
fn convert_ip_usage<T>(ip: ts_control_serde::DerpIpUsage<T>) -> ts_transport_derp::IpUsage<T>
80+
fn convert_ip_usage<T>(ip: ts_control_serde::DerpIpUsage<T>) -> ts_derp::IpUsage<T>
8181
where
8282
T: Copy,
8383
{
8484
match ip {
85-
ts_control_serde::DerpIpUsage::Disable => ts_transport_derp::IpUsage::Disable,
86-
ts_control_serde::DerpIpUsage::UseDns => ts_transport_derp::IpUsage::UseDns,
87-
ts_control_serde::DerpIpUsage::FixedAddr(ip) => ts_transport_derp::IpUsage::FixedAddr(ip),
85+
ts_control_serde::DerpIpUsage::Disable => ts_derp::IpUsage::Disable,
86+
ts_control_serde::DerpIpUsage::UseDns => ts_derp::IpUsage::UseDns,
87+
ts_control_serde::DerpIpUsage::FixedAddr(ip) => ts_derp::IpUsage::FixedAddr(ip),
8888
}
8989
}

ts_control/src/map_request_builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl<'a> MapRequestBuilder<'a> {
6767

6868
/// Set the [`NetInfo::preferred_derp`] field (inside [`MapRequest::host_info`] ->
6969
/// [`HostInfo::net_info`]).
70-
pub fn preferred_derp(mut self, value: ts_transport_derp::RegionId) -> Self {
70+
pub fn preferred_derp(mut self, value: ts_derp::RegionId) -> Self {
7171
self.net_info_mut().preferred_derp = Some(value.0.into());
7272
self
7373
}

ts_control/src/node.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub struct Node {
4646
pub underlay_addresses: Vec<SocketAddr>,
4747

4848
/// The DERP region for this node, if known.
49-
pub derp_region: Option<ts_transport_derp::RegionId>,
49+
pub derp_region: Option<ts_derp::RegionId>,
5050
}
5151

5252
impl Node {
@@ -166,7 +166,7 @@ impl From<&ts_control_serde::Node<'_>> for Node {
166166
.home_derp
167167
.or(value.legacy_derp_string)
168168
.or_else(|| value.host_info.net_info.as_ref()?.preferred_derp)
169-
.map(|x| ts_transport_derp::RegionId(x.into())),
169+
.map(|x| ts_derp::RegionId(x.into())),
170170
}
171171
}
172172
}

0 commit comments

Comments
 (0)