diff --git a/prototypes/quic_demo/src/bin/quic_demo_client.rs b/prototypes/quic_demo/src/bin/quic_demo_client.rs index 20bd5c1..41817e6 100644 --- a/prototypes/quic_demo/src/bin/quic_demo_client.rs +++ b/prototypes/quic_demo/src/bin/quic_demo_client.rs @@ -89,30 +89,13 @@ impl P2Client { ) -> anyhow::Result <()> { let running = true; while running { - let (tcp_socket, _) = listener.accept ().await?; + let (tcp_stream, _) = listener.accept ().await?; let connection = connection.clone (); let server_id = conf.server_id.clone (); let server_tcp_port = conf.server_tcp_port; tokio::spawn (async move { - let (local_recv, local_send) = tcp_socket.into_split (); - - debug! ("Starting PTTH connection"); - - let (relay_send, relay_recv) = protocol::p2_connect_to_p5 (&connection, &server_id, server_tcp_port).await?; - - trace! ("Relaying bytes..."); - - let ptth_conn = quic_demo::connection::NewConnection { - local_send, - local_recv, - relay_send, - relay_recv, - }.build (); - - ptth_conn.wait_for_close ().await?; - - debug! ("Ended PTTH connection"); + Self::run_tcp_stream (&connection, tcp_stream, &server_id, server_tcp_port).await?; Ok::<_, anyhow::Error> (()) }); @@ -124,16 +107,16 @@ impl P2Client { /// Forwards a single TCP stream async fn run_tcp_stream ( - connection: quinn::Connection, - tcp_socket: TcpStream, + connection: &quinn::Connection, + tcp_stream: TcpStream, server_id: &str, server_tcp_port: u16, ) -> anyhow::Result <()> { - let (local_recv, local_send) = tcp_socket.into_split (); + let (local_recv, local_send) = tcp_stream.into_split (); debug! ("Starting PTTH connection"); - let (relay_send, relay_recv) = protocol::p2_connect_to_p5 (&connection, server_id, server_tcp_port).await?; + let (relay_send, relay_recv) = protocol::p2_connect_to_p5 (connection, server_id, server_tcp_port).await?; trace! ("Relaying bytes...");