@@ -12,15 +12,16 @@ impl WsProxy {
1212 client_ws : WebSocket ,
1313 downstream_url : & str ,
1414 ) -> Result < ( ) , WsProxyError > {
15- info ! ( "Establishing connection to downstream WebSocket: {}" , downstream_url) ;
15+ info ! (
16+ "Establishing connection to downstream WebSocket: {}" ,
17+ downstream_url
18+ ) ;
1619
1720 // Connect to downstream WebSocket server
18- let ( downstream_ws, _) = connect_async ( downstream_url)
19- . await
20- . map_err ( |e| {
21- error ! ( "Failed to connect to downstream WebSocket: {}" , e) ;
22- WsProxyError :: ConnectionFailed ( e. to_string ( ) )
23- } ) ?;
21+ let ( downstream_ws, _) = connect_async ( downstream_url) . await . map_err ( |e| {
22+ error ! ( "Failed to connect to downstream WebSocket: {}" , e) ;
23+ WsProxyError :: ConnectionFailed ( e. to_string ( ) )
24+ } ) ?;
2425
2526 info ! ( "Successfully connected to downstream WebSocket" ) ;
2627
@@ -32,7 +33,10 @@ impl WsProxy {
3233 while let Some ( msg) = client_read. next ( ) . await {
3334 match msg {
3435 Ok ( Message :: Text ( buffer) ) => {
35- info ! ( "Client -> Downstream: Text message ({} bytes)" , buffer. len( ) ) ;
36+ info ! (
37+ "Client -> Downstream: Text message ({} bytes)" ,
38+ buffer. len( )
39+ ) ;
3640 if let Err ( e) = downstream_write
3741 . send ( TungsteniteMessage :: Text ( buffer. to_string ( ) ) )
3842 . await
@@ -42,7 +46,10 @@ impl WsProxy {
4246 }
4347 }
4448 Ok ( Message :: Binary ( data) ) => {
45- info ! ( "Client -> Downstream: Binary message ({} bytes)" , data. len( ) ) ;
49+ info ! (
50+ "Client -> Downstream: Binary message ({} bytes)" ,
51+ data. len( )
52+ ) ;
4653 if let Err ( e) = downstream_write
4754 . send ( TungsteniteMessage :: Binary ( data. into ( ) ) )
4855 . await
@@ -96,7 +103,10 @@ impl WsProxy {
96103 }
97104 }
98105 Ok ( TungsteniteMessage :: Binary ( data) ) => {
99- info ! ( "Downstream -> Client: Binary message ({} bytes)" , data. len( ) ) ;
106+ info ! (
107+ "Downstream -> Client: Binary message ({} bytes)" ,
108+ data. len( )
109+ ) ;
100110 if let Err ( e) = client_write. send ( Message :: Binary ( data. into ( ) ) ) . await {
101111 error ! ( "Failed to forward binary message to client: {}" , e) ;
102112 break ;
@@ -153,4 +163,3 @@ pub enum WsProxyError {
153163 #[ error( "Failed to connect to downstream WebSocket: {0}" ) ]
154164 ConnectionFailed ( String ) ,
155165}
156-
0 commit comments