From cb78de4f37a4392df393a8549fd93ed256c819f0 Mon Sep 17 00:00:00 2001 From: xah30 Date: Mon, 25 May 2026 18:10:17 +0300 Subject: [PATCH] feat(transport): pin PacketConnection contract for the router seam Define the async PacketConnection trait (send_packet/recv_packet over &self) that aura-tunnel's router consumes and the QUIC connection will implement. Committed before Wave 3 so the transport and tunnel agents build against a stable cross-crate contract from isolated worktrees. Co-Authored-By: Claude Opus 4.7 --- Cargo.lock | 1 + Cargo.toml | 1 + crates/aura-transport/Cargo.toml | 1 + crates/aura-transport/src/conn.rs | 20 ++++++++++++++++++++ crates/aura-transport/src/lib.rs | 10 +++++++++- 5 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 crates/aura-transport/src/conn.rs diff --git a/Cargo.lock b/Cargo.lock index c41585f..c1c7cb4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -263,6 +263,7 @@ name = "aura-transport" version = "0.1.0" dependencies = [ "anyhow", + "async-trait", "aura-crypto", "aura-proto", "bytes", diff --git a/Cargo.toml b/Cargo.toml index 19e0ba4..05dcfb7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -77,6 +77,7 @@ tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } anyhow = "1" thiserror = "1" +async-trait = "0.1" # Dev / bench criterion = "0.5" diff --git a/crates/aura-transport/Cargo.toml b/crates/aura-transport/Cargo.toml index c3b76dd..4ca9a07 100644 --- a/crates/aura-transport/Cargo.toml +++ b/crates/aura-transport/Cargo.toml @@ -17,3 +17,4 @@ rand.workspace = true tracing.workspace = true thiserror.workspace = true anyhow.workspace = true +async-trait.workspace = true diff --git a/crates/aura-transport/src/conn.rs b/crates/aura-transport/src/conn.rs new file mode 100644 index 0000000..8f8096b --- /dev/null +++ b/crates/aura-transport/src/conn.rs @@ -0,0 +1,20 @@ +//! The transport's full-duplex packet-connection abstraction. +//! +//! [`PacketConnection`] is the seam between this crate (QUIC transport + the post-handshake +//! `aura_proto::Session`) and `aura-tunnel`'s router. The router reads IP packets from the TUN +//! device and `send_packet`s the ones routed through the VPN, while a second task `recv_packet`s +//! decrypted IP packets to write back to the TUN. The methods take `&self` (not `&mut self`) so a +//! single connection can be shared — e.g. behind `Arc` — across the +//! concurrent send and receive tasks. + +use async_trait::async_trait; + +/// A bidirectional, encrypted packet pipe to the peer (one IP packet per call). +#[async_trait] +pub trait PacketConnection: Send + Sync { + /// Encrypt and send one IP packet to the peer. + async fn send_packet(&self, packet: &[u8]) -> anyhow::Result<()>; + + /// Receive and decrypt one IP packet from the peer. Returns the plaintext IP packet. + async fn recv_packet(&self) -> anyhow::Result>; +} diff --git a/crates/aura-transport/src/lib.rs b/crates/aura-transport/src/lib.rs index 4da987f..848e7e7 100644 --- a/crates/aura-transport/src/lib.rs +++ b/crates/aura-transport/src/lib.rs @@ -1 +1,9 @@ -//! aura-transport — QUIC transport and traffic mimicry (skeleton; implemented in Wave 3). +//! aura-transport — QUIC transport, HTTPS/H3 traffic mimicry, and the packet-connection seam. +//! +//! Implemented in Wave 3. This file currently pins the cross-crate [`PacketConnection`] contract +//! consumed by `aura-tunnel`'s router; the QUIC endpoint (quinn), mimicry, and padding land +//! alongside it in the `quic`, `mimicry`, and `padding` modules. + +pub mod conn; + +pub use conn::PacketConnection;