mirror of
https://github.com/jmcorgan/fips.git
synced 2026-07-30 19:46:15 +00:00
transport: promote FMP stream framing to transport::framing
The FMP frame-boundary reader lived in transport/tcp/stream.rs, but the Tor and Nym transports both reached across module boundaries to 'use crate::transport::tcp::stream::read_fmp_packet', a layering smell: the reader is a shared stream-framing utility, not a TCP-private one. Move the file to transport/framing.rs and repoint the tcp/tor/nym use sites, removing the tor->tcp and nym->tcp dependencies. Behavior unchanged.
This commit is contained in:
@@ -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};
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user