From d67908f27e591cd393d7f416e7083c210492d875 Mon Sep 17 00:00:00 2001 From: zonyitoo Date: Tue, 13 Aug 2024 23:30:51 +0800 Subject: [PATCH] feat(shadowsocks): ProxyServerStream::from_stream made public (#1613) --- .../shadowsocks/src/relay/tcprelay/proxy_listener.rs | 2 +- .../src/relay/tcprelay/proxy_stream/server.rs | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/shadowsocks/src/relay/tcprelay/proxy_listener.rs b/crates/shadowsocks/src/relay/tcprelay/proxy_listener.rs index 2c1c7764c88d..055393c27ae3 100644 --- a/crates/shadowsocks/src/relay/tcprelay/proxy_listener.rs +++ b/crates/shadowsocks/src/relay/tcprelay/proxy_listener.rs @@ -78,7 +78,7 @@ impl ProxyListener { let stream = map_fn(stream); // Create a ProxyServerStream and read the target address from it - let stream = ProxyServerStream::from_stream( + let stream = ProxyServerStream::from_stream_with_user_manager( self.context.clone(), stream, self.method, diff --git a/crates/shadowsocks/src/relay/tcprelay/proxy_stream/server.rs b/crates/shadowsocks/src/relay/tcprelay/proxy_stream/server.rs index a2005bdac60a..374d9d3ce468 100644 --- a/crates/shadowsocks/src/relay/tcprelay/proxy_stream/server.rs +++ b/crates/shadowsocks/src/relay/tcprelay/proxy_stream/server.rs @@ -42,7 +42,15 @@ pub struct ProxyServerStream { } impl ProxyServerStream { - pub(crate) fn from_stream( + /// Create a `ProxyServerStream` from a connection stream + pub fn from_stream(context: SharedContext, stream: S, method: CipherKind, key: &[u8]) -> ProxyServerStream { + ProxyServerStream::from_stream_with_user_manager(context, stream, method, key, None) + } + + /// Create a `ProxyServerStream` from a connection stream + /// + /// Set `user_manager` to enable support of verifying EIH users. + pub fn from_stream_with_user_manager( context: SharedContext, stream: S, method: CipherKind,