11use std:: { io, sync:: Arc , time:: Duration } ;
22
3+ use crate :: service:: config:: TransformerContext ;
34use nohash_hasher:: IntMap ;
45use tokio_util:: codec:: LengthDelimitedCodec ;
56
@@ -217,9 +218,33 @@ where
217218 #[ cfg( not( target_family = "wasm" ) ) ]
218219 pub fn tcp_config < F > ( mut self , f : F ) -> Self
219220 where
220- F : Fn ( TcpSocket ) -> Result < TcpSocket , std:: io:: Error > + Send + Sync + ' static ,
221+ F : Fn ( TcpSocket , TransformerContext ) -> Result < TcpSocket , std:: io:: Error >
222+ + Send
223+ + Sync
224+ + ' static ,
221225 {
222- self . config . tcp_config . tcp = Arc :: new ( f) ;
226+ self . config . tcp_config . tcp . socket_transformer = Arc :: new ( f) ;
227+ self
228+ }
229+
230+ /// Proxy config for tcp
231+ #[ cfg( not( target_family = "wasm" ) ) ]
232+ pub fn tcp_proxy_config ( mut self , proxy_url : String ) -> Self {
233+ self . config . tcp_config . tcp . proxy_url = Some ( proxy_url) ;
234+ self
235+ }
236+
237+ /// Onion config for tcp
238+ #[ cfg( not( target_family = "wasm" ) ) ]
239+ pub fn tcp_onion_config ( mut self , onion_url : String ) -> Self {
240+ self . config . tcp_config . tcp . onion_url = Some ( onion_url) ;
241+ self
242+ }
243+
244+ /// Onion config for tcp
245+ #[ cfg( not( target_family = "wasm" ) ) ]
246+ pub fn tcp_onion_random_socks_auth ( mut self , onion_random_socks_auth : bool ) -> Self {
247+ self . config . tcp_config . tcp . onion_random_socks_auth = onion_random_socks_auth;
223248 self
224249 }
225250
@@ -228,9 +253,12 @@ where
228253 #[ cfg_attr( docsrs, doc( cfg( feature = "ws" ) ) ) ]
229254 pub fn tcp_config_on_ws < F > ( mut self , f : F ) -> Self
230255 where
231- F : Fn ( TcpSocket ) -> Result < TcpSocket , std:: io:: Error > + Send + Sync + ' static ,
256+ F : Fn ( TcpSocket , TransformerContext ) -> Result < TcpSocket , std:: io:: Error >
257+ + Send
258+ + Sync
259+ + ' static ,
232260 {
233- self . config . tcp_config . ws = Arc :: new ( f) ;
261+ self . config . tcp_config . ws . socket_transformer = Arc :: new ( f) ;
234262 self
235263 }
236264
@@ -252,9 +280,12 @@ where
252280 #[ cfg_attr( docsrs, doc( cfg( feature = "tls" ) ) ) ]
253281 pub fn tcp_config_on_tls < F > ( mut self , f : F ) -> Self
254282 where
255- F : Fn ( TcpSocket ) -> Result < TcpSocket , std:: io:: Error > + Send + Sync + ' static ,
283+ F : Fn ( TcpSocket , TransformerContext ) -> Result < TcpSocket , std:: io:: Error >
284+ + Send
285+ + Sync
286+ + ' static ,
256287 {
257- self . config . tcp_config . tls = Arc :: new ( f) ;
288+ self . config . tcp_config . tls . socket_transformer = Arc :: new ( f) ;
258289 self
259290 }
260291}
0 commit comments