From 2cef528c862c1906ae5d3bc8a2aa037050900f0e Mon Sep 17 00:00:00 2001 From: cfal Date: Thu, 22 Oct 2026 10:49:30 +0000 Subject: [PATCH] Keep REALITY client and server handlers in the same module --- src/lib.rs | 1 - src/main.rs | 1 - src/reality/mod.rs | 2 ++ src/{ => reality}/reality_client_handler.rs | 6 +++--- src/tcp/tcp_client_handler_factory.rs | 4 ++-- src/tls_client_handler.rs | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) rename src/{ => reality}/reality_client_handler.rs (96%) diff --git a/src/lib.rs b/src/lib.rs index 1db6bfd1..1e7beaf1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -67,7 +67,6 @@ mod quic_endpoint; mod quic_server; mod quic_stream; mod reality; -mod reality_client_handler; pub mod resolver; pub mod resources; mod routing; diff --git a/src/main.rs b/src/main.rs index 18e82ef0..543580d2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -25,7 +25,6 @@ mod quic_endpoint; mod quic_server; mod quic_stream; mod reality; -mod reality_client_handler; mod resolver; mod resources; mod routing; diff --git a/src/reality/mod.rs b/src/reality/mod.rs index 231091fb..a8f67718 100644 --- a/src/reality/mod.rs +++ b/src/reality/mod.rs @@ -5,6 +5,7 @@ mod reality_certificate; mod reality_certificate_verify; mod reality_cipher_suite; mod reality_client; +mod reality_client_handler; mod reality_config; mod reality_hello; mod reality_mldsa; @@ -36,5 +37,6 @@ pub use reality_config::{ }; pub use reality_client::RealityClientConfig; +pub use reality_client_handler::RealityClientHandler; pub use reality_server::RealityServerConfig; pub use reality_server_handler::{RealityServerTarget, setup_reality_server_stream}; diff --git a/src/reality_client_handler.rs b/src/reality/reality_client_handler.rs similarity index 96% rename from src/reality_client_handler.rs rename to src/reality/reality_client_handler.rs index d13d65f5..3745475d 100644 --- a/src/reality_client_handler.rs +++ b/src/reality/reality_client_handler.rs @@ -2,15 +2,15 @@ use async_trait::async_trait; +use super::{CipherSuite, Mldsa65VerifyKey, RealityClientConfig}; use crate::address::ResolvedLocation; use crate::async_stream::AsyncStream; use crate::crypto::{CryptoTlsStream, TlsReadMode}; -use crate::reality::{CipherSuite, RealityClientConfig}; use crate::tcp::tcp_handler::{TcpClientHandler, TcpClientSetupResult}; #[derive(Debug)] pub struct RealityClientHandler { - mldsa65_verify: Option, + mldsa65_verify: Option, public_key: [u8; 32], short_id: [u8; 8], server_name: rustls::pki_types::ServerName<'static>, @@ -62,7 +62,7 @@ impl RealityClientHandler { } } - pub fn with_mldsa65_verify(mut self, key: Option) -> Self { + pub fn with_mldsa65_verify(mut self, key: Option) -> Self { self.mldsa65_verify = key; self } diff --git a/src/tcp/tcp_client_handler_factory.rs b/src/tcp/tcp_client_handler_factory.rs index c5ac8d96..6859dc43 100644 --- a/src/tcp/tcp_client_handler_factory.rs +++ b/src/tcp/tcp_client_handler_factory.rs @@ -285,7 +285,7 @@ pub fn create_tcp_client_handler( .expect("Invalid user_id UUID") .into_boxed_slice(); Box::new( - crate::reality_client_handler::RealityClientHandler::new_vision_vless( + crate::reality::RealityClientHandler::new_vision_vless( public_key_bytes, short_id_bytes, server_name, @@ -298,7 +298,7 @@ pub fn create_tcp_client_handler( } else { let inner_handler = create_tcp_client_handler(*protocol, None, resolver.clone())?; Box::new( - crate::reality_client_handler::RealityClientHandler::new( + crate::reality::RealityClientHandler::new( public_key_bytes, short_id_bytes, server_name, diff --git a/src/tls_client_handler.rs b/src/tls_client_handler.rs index 3573652b..8fbc81ca 100644 --- a/src/tls_client_handler.rs +++ b/src/tls_client_handler.rs @@ -181,7 +181,7 @@ mod tests { #[tokio::test] async fn only_default_tls_and_reality_handlers_forward_reuse() { - use crate::reality_client_handler::RealityClientHandler; + use crate::reality::RealityClientHandler; let config = Arc::new( rustls::ClientConfig::builder() .with_root_certificates(rustls::RootCertStore::empty())