diff --git a/Cargo.lock b/Cargo.lock index b4fc428..e003db7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2418,6 +2418,7 @@ version = "0.1.0" dependencies = [ "anyhow", "tokio", + "tracing", ] [[package]] diff --git a/crates/ptth_quic/src/executable_end_server.rs b/crates/ptth_quic/src/executable_end_server.rs index 9cfbb57..e715f80 100644 --- a/crates/ptth_quic/src/executable_end_server.rs +++ b/crates/ptth_quic/src/executable_end_server.rs @@ -100,7 +100,7 @@ pub struct P4EndServer { impl P4EndServer { pub (crate) async fn connect (conf: Config) -> anyhow::Result <(Self, watch::Sender )> { - trace! ("P4 end server making its QUIC endpoint"); + debug! ("P4 end server making its QUIC endpoint"); let endpoint = make_client_endpoint ("0.0.0.0:0".parse ()?, &[&conf.relay_cert])?; let conf = if conf.use_udp_over_tcp { @@ -128,7 +128,7 @@ impl P4EndServer { conf }; - trace! ("P4 end server connecting to P3 relay server"); + debug! ("P4 end server connecting to P3 relay server"); let conn = protocol::p4_connect_to_p3 ( &endpoint, conf.relay_addr, diff --git a/crates/ptth_quic/src/protocol.rs b/crates/ptth_quic/src/protocol.rs index 3c42682..60e2baa 100644 --- a/crates/ptth_quic/src/protocol.rs +++ b/crates/ptth_quic/src/protocol.rs @@ -257,7 +257,7 @@ pub async fn p4_connect_to_p3 ( bail! ("Server ID is longer than MAX_ID_LENGTH"); } - let new_conn = endpoint.connect (relay_addr, "localhost")?.await?; + let new_conn = endpoint.connect (relay_addr, "localhost")?.await.context ("UXTDVL2V quinn::Endpoint::connect")?; let (mut send, mut recv) = new_conn.open_bi ().await?; let cmd_type = Command::CONNECT_P4_TO_P3.0; @@ -265,7 +265,7 @@ pub async fn p4_connect_to_p3 ( send_lv_string (&mut send, server_id).await?; expect_exact_response (&mut recv, [Command::OKAY.0, cmd_type, 0, 0]).await - .context ("P4 didn't get OK response when connecting to P3")?; + .context ("WMGW2RXU P4 didn't get OK response when connecting to P3")?; Ok (new_conn) } diff --git a/crates/udp_over_tcp/Cargo.toml b/crates/udp_over_tcp/Cargo.toml index bae2954..35fc267 100644 --- a/crates/udp_over_tcp/Cargo.toml +++ b/crates/udp_over_tcp/Cargo.toml @@ -6,5 +6,6 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -anyhow = "1.0.38" -tokio = { version = "1.8.1", features = ["full"] } +anyhow = "1.0.66" +tokio = { version = "1.23.0", features = ["full"] } +tracing = "0.1.37" diff --git a/crates/udp_over_tcp/src/loops.rs b/crates/udp_over_tcp/src/loops.rs index d71ccb5..1aaa669 100644 --- a/crates/udp_over_tcp/src/loops.rs +++ b/crates/udp_over_tcp/src/loops.rs @@ -17,7 +17,12 @@ pub async fn rx ( udp_sock: Arc , mut tcp_read: tcp::OwnedReadHalf, ) -> anyhow::Result <()> { - loop { + for i in 0u64.. { + // Optimizes down to a bitwise AND + if i % 8_192 == 0 { + tracing::trace! ("rx loop"); + } + let mut tag = [0u8, 0, 0, 0]; let bytes_read = tcp_read.read (&mut tag).await?; if bytes_read != 4 { @@ -47,6 +52,8 @@ pub async fn rx ( udp_sock.send (&buf).await?; } + + Ok (()) } pub async fn tx ( @@ -54,7 +61,12 @@ pub async fn tx ( mut tcp_write: tcp::OwnedWriteHalf, ) -> anyhow::Result <()> { - loop { + for i in 0u64.. { + // Optimizes down to a bitwise AND + if i % 8_192 == 0 { + tracing::trace! ("tx loop"); + } + let mut buf = vec! [0u8; 8_192]; let bytes_read = udp_sock.recv (&mut buf).await?; buf.truncate (bytes_read); @@ -66,4 +78,6 @@ pub async fn tx ( tcp_write.write_all (&length).await?; tcp_write.write_all (&buf).await?; } + + Ok (()) }