Files
wanderbooks/crates/relay/src/lib.rs
T
swaitsandClaude Fable 5.2 31f706bd7e feat(relay): the relay service for wanderbooks.link (P15 unit B2)
A new crate, crates/relay (lib `relay`, binary wanderbooks-relay), with no
ledger-* dependency. Routes an assistant's TLS connection by the server name
in its ClientHello down the line an app holds open, forwarding encrypted
bytes only; the line is yamux over TLS 1.3 on 443, the app proving its key
with an Ed25519 signature bound to the session's TLS exporter and a fresh
nonce. One durable table (SQLite: name, key, created, blocked), four-word
names from a curated list of 1454 words (42.0 bits), a PROXY v2 header with
the caller's address, an authoritative DNS server that publishes an app's
ACME DNS-01 value for its own name only, and a list of certificate
authorities served as data. Every table, queue, buffer and time is bounded.

New dependencies, each permissive and passing cargo deny: yamux 0.14
(Apache-2.0 OR MIT; the multiplexer), hickory-proto 0.26 (MIT OR Apache-2.0;
DNS wire format, std only), rusqlite (already in the tree), rustls and
tokio-rustls (already in the tree, ring provider), ring (Ed25519, already in
the tree); dev only: rcgen 0.14 (MIT OR Apache-2.0), proptest, tempfile.
Added to the kernel-only lint list (no Decimal in the crate).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 09:33:03 -07:00

55 lines
2.0 KiB
Rust

//! The relay for `wanderbooks.link`.
//!
//! A person runs the Wanderbooks desktop app at home. Web assistants can
//! only call servers on the public internet. The app dials out to this
//! relay and holds one multiplexed line open; the relay routes an
//! assistant's incoming TLS connection, by its server name, down that
//! line to the app. The relay never holds the app's private key and
//! cannot read the traffic: it forwards encrypted bytes. It is also the
//! domain's authoritative DNS server, which lets an app prove its own
//! name to a certificate authority and no other.
//!
//! The crate depends on no `ledger-*` crate. The modules [`proto`],
//! [`names`] and [`client`] are the app's side of the protocol too.
//!
//! ```text
//! GOAL: let a web assistant reach an app behind a home network, with
//! the relay unable to read anything, unable to be made to hold
//! unbounded memory, and unable to give a stranger an app's name
//! or a certificate for it.
//! SOURCE: WB-relay-1 (the router), WB-relay-2 (the line and its proof),
//! WB-relay-3 (names), WB-relay-4 (the registry), WB-relay-5
//! (proof records, DNS and authorities), WB-relay-6 (the
//! caller's address), WB-relay-7 (bounds); D-80, D-82, D-85, D-87.
//! INVARIANTS:
//! 1. No unsafe code anywhere in the crate.
//! 2. The relay holds no key or certificate for any app and never
//! decrypts an app's traffic.
//! 3. The only durable state is the registry (name, key, created,
//! blocked); proof records live minutes, in memory.
//! SCENARIOS:
//! 1. See `tests/relay.rs`: a real TLS client reaches a real TLS
//! server through the relay, and the relay never sees plaintext.
//! ```
#![forbid(unsafe_code)]
pub mod authorities;
pub mod client;
pub mod config;
pub mod dns;
pub mod front;
pub mod gate;
pub mod hello;
pub mod mux;
pub mod names;
pub mod proto;
pub mod registry;
pub mod server;
pub mod splice;
pub mod tls;
pub mod txt;
pub use config::{Config, Limits};
pub use server::Relay;