diff --git a/src/transport/tcp/stream.rs b/src/transport/framing.rs similarity index 99% rename from src/transport/tcp/stream.rs rename to src/transport/framing.rs index 4323fdc..4fe0f24 100644 --- a/src/transport/tcp/stream.rs +++ b/src/transport/framing.rs @@ -3,8 +3,8 @@ //! Recovers FIPS packet boundaries from a TCP byte stream using the //! existing 4-byte FMP common prefix `[ver+phase:1][flags:1][payload_len:2 LE]`. //! -//! This module is deliberately separate from the TCP transport so it can -//! be reused by the future Tor transport. +//! This module is deliberately separate from any single transport so it can +//! be shared by the stream-oriented transports (TCP, Tor, Nym). use tokio::io::{AsyncRead, AsyncReadExt}; diff --git a/src/transport/mod.rs b/src/transport/mod.rs index 9dacc17..1176215 100644 --- a/src/transport/mod.rs +++ b/src/transport/mod.rs @@ -34,6 +34,8 @@ use tor::TorTransport; use tor::control::TorMonitoringInfo; use udp::UdpTransport; +pub(crate) mod framing; + mod stats_common; pub(crate) use stats_common::PoolCounters; diff --git a/src/transport/nym/mod.rs b/src/transport/nym/mod.rs index 4996664..053677f 100644 --- a/src/transport/nym/mod.rs +++ b/src/transport/nym/mod.rs @@ -9,7 +9,7 @@ //! //! Outbound-only: connects to remote TCP peers through the local //! nym-socks5-client SOCKS5 proxy. Like the Tor transport, reuses FMP -//! stream framing from `tcp::stream` and follows the same connection +//! stream framing from `transport::framing` and follows the same connection //! pool pattern. No inbound service is supported. pub mod stats; @@ -22,7 +22,7 @@ use super::{ TransportError, TransportId, TransportState, TransportType, }; use crate::config::NymConfig; -use crate::transport::tcp::stream::read_fmp_packet; +use crate::transport::framing::read_fmp_packet; use stats::NymStats; use futures::FutureExt; diff --git a/src/transport/tcp/mod.rs b/src/transport/tcp/mod.rs index 350c879..b1975b8 100644 --- a/src/transport/tcp/mod.rs +++ b/src/transport/tcp/mod.rs @@ -23,7 +23,6 @@ //! TCP stream and the receiver uses phase-dependent size computation. pub mod stats; -pub mod stream; use super::resolve_socket_addr; use super::{ @@ -31,8 +30,8 @@ use super::{ TransportError, TransportId, TransportState, TransportType, }; use crate::config::TcpConfig; +use crate::transport::framing::read_fmp_packet; use stats::TcpStats; -use stream::read_fmp_packet; use futures::FutureExt; use socket2::TcpKeepalive; diff --git a/src/transport/tor/mod.rs b/src/transport/tor/mod.rs index 5c2b8a9..e183632 100644 --- a/src/transport/tor/mod.rs +++ b/src/transport/tor/mod.rs @@ -14,8 +14,8 @@ //! ## Architecture //! //! Like TCP, each peer has its own connection. The transport reuses FMP -//! stream framing from `tcp::stream` and follows the same connection pool -//! pattern as the TCP transport. Inbound connections arrive via a local +//! stream framing from `transport::framing` and follows the same connection +//! pool pattern as the TCP transport. Inbound connections arrive via a local //! TCP listener that the Tor daemon forwards onion service traffic to. pub mod control; @@ -31,7 +31,7 @@ use super::{ TransportError, TransportId, TransportState, TransportType, }; use crate::config::TorConfig; -use crate::transport::tcp::stream::read_fmp_packet; +use crate::transport::framing::read_fmp_packet; use control::{ControlAuth, TorControlClient, TorMonitoringInfo}; use stats::TorStats;