From 1a775622cfd0606cf0684199167236431b88ca21 Mon Sep 17 00:00:00 2001 From: _ <> Date: Sun, 10 Oct 2021 18:24:35 +0000 Subject: [PATCH] :bug: bug: fix compile bugs for tests --- Cargo.lock | 1 + crates/ptth_multi_call_server/Cargo.toml | 1 + crates/ptth_multi_call_server/src/main.rs | 14 +++++++++++++- prototypes/quic_demo/src/bin/quic_demo_client.rs | 4 ++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index baec8a4..4100aa0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1228,6 +1228,7 @@ name = "ptth_multi_call_server" version = "0.1.0" dependencies = [ "anyhow", + "ctrlc", "ptth_file_server", "ptth_server", "quic_demo", diff --git a/crates/ptth_multi_call_server/Cargo.toml b/crates/ptth_multi_call_server/Cargo.toml index 2357804..5142e40 100644 --- a/crates/ptth_multi_call_server/Cargo.toml +++ b/crates/ptth_multi_call_server/Cargo.toml @@ -7,6 +7,7 @@ license = "AGPL-3.0" [dependencies] anyhow = "1.0.38" +ctrlc = "3.2.1" ptth_file_server = { path = "../ptth_file_server_bin" } ptth_server = { path = "../ptth_server" } quic_demo = { path = "../../prototypes/quic_demo" } diff --git a/crates/ptth_multi_call_server/src/main.rs b/crates/ptth_multi_call_server/src/main.rs index f26415a..dd14ce0 100644 --- a/crates/ptth_multi_call_server/src/main.rs +++ b/crates/ptth_multi_call_server/src/main.rs @@ -3,6 +3,8 @@ use std::{ iter::FromIterator, }; +use tokio::sync::watch; + #[derive (Clone, Copy, Debug, PartialEq)] enum Subcommand { PtthServer, @@ -20,7 +22,17 @@ async fn main () -> anyhow::Result <()> { match subcommand { Subcommand::PtthServer => ptth_server::executable::main (&args).await, Subcommand::PtthFileServer => ptth_file_server::main (&args).await, - Subcommand::PtthQuicEndServer => quic_demo::executable_end_server::main (&args).await, + Subcommand::PtthQuicEndServer => { + let (shutdown_tx, shutdown_rx) = watch::channel (false); + + ctrlc::set_handler (move || { + shutdown_tx.send (true).expect ("Couldn't forward Ctrl+C signal"); + })?; + tracing::trace! ("Set Ctrl+C handler"); + quic_demo::executable_end_server::main (&args, Some (shutdown_rx)).await?; + + Ok (()) + } } } diff --git a/prototypes/quic_demo/src/bin/quic_demo_client.rs b/prototypes/quic_demo/src/bin/quic_demo_client.rs index 57e149c..6208d31 100644 --- a/prototypes/quic_demo/src/bin/quic_demo_client.rs +++ b/prototypes/quic_demo/src/bin/quic_demo_client.rs @@ -79,8 +79,12 @@ impl P2Client { let server_id = conf.server_id.clone (); let server_tcp_port = conf.server_tcp_port; + let listener = TcpListener::bind (("127.0.0.1", client_tcp_port)).await?; + trace! ("Accepting local TCP connections from P1 on {}", client_tcp_port); + tokio::spawn (async move { forward_port ( + listener, connection, ForwardingParams { client_tcp_port,