🔇 drop some debugs to traces

main
_ 2021-07-17 21:42:51 +00:00
parent 3442bf220b
commit 4f3424f482
4 changed files with 23 additions and 18 deletions

View File

@ -12,7 +12,7 @@ async fn main () -> anyhow::Result <()> {
let server_addr = "127.0.0.1:30380".parse ()?;
let endpoint = make_client_endpoint ("0.0.0.0:0".parse ()?, &[&server_cert])?;
debug! ("Connecting to relay server");
trace! ("Connecting to relay server");
let quinn::NewConnection {
connection,
@ -29,7 +29,7 @@ async fn main () -> anyhow::Result <()> {
let listener = TcpListener::bind ("127.0.0.1:30381").await?;
debug! ("Accepting local TCP connections from P1");
trace! ("Accepting local TCP connections from P1");
loop {
let (tcp_socket, _) = listener.accept ().await?;
@ -38,7 +38,7 @@ async fn main () -> anyhow::Result <()> {
tokio::spawn (async move {
let (local_recv, local_send) = tcp_socket.into_split ();
debug! ("Connecting to end server");
debug! ("Started PTTH connection");
let (mut relay_send, mut relay_recv) = connection.open_bi ().await?;
@ -48,7 +48,7 @@ async fn main () -> anyhow::Result <()> {
let mut resp_buf = [0; 8];
relay_recv.read_exact (&mut resp_buf).await?;
debug! ("Relaying bytes...");
trace! ("Relaying bytes...");
let ptth_conn = PtthNewConnection {
local_send,
@ -60,6 +60,8 @@ async fn main () -> anyhow::Result <()> {
ptth_conn.uplink_task.await??;
ptth_conn.downlink_task.await??;
debug! ("Ended PTTH connection");
Ok::<_, anyhow::Error> (())
});
}
@ -96,7 +98,7 @@ impl PtthNewConnection {
break;
}
let buf_slice = &buf [0..bytes_read];
debug! ("Uplink relaying {} bytes", bytes_read);
trace! ("Uplink relaying {} bytes", bytes_read);
relay_send.write_all (buf_slice).await?;
}
@ -111,7 +113,7 @@ impl PtthNewConnection {
let mut buf = vec! [0u8; 65_536];
while let Some (bytes_read) = relay_recv.read (&mut buf).await? {
let buf_slice = &buf [0..bytes_read];
debug! ("Downlink relaying {} bytes", bytes_read);
trace! ("Downlink relaying {} bytes", bytes_read);
local_send.write_all (buf_slice).await?;
}

View File

@ -10,7 +10,7 @@ async fn main () -> anyhow::Result <()> {
let server_addr = "127.0.0.1:30380".parse ()?;
let endpoint = make_client_endpoint ("0.0.0.0:0".parse ()?, &[&server_cert])?;
debug! ("Connecting to relay server");
trace! ("Connecting to relay server");
let quinn::NewConnection {
connection,
@ -26,7 +26,7 @@ async fn main () -> anyhow::Result <()> {
let mut resp_buf = [0u8, 0, 0, 0];
recv.read_exact (&mut resp_buf).await?;
debug! ("Accepting bi streams from P3");
trace! ("Accepting bi streams from P3");
loop {
let (mut relay_send, mut relay_recv) = bi_streams.next ().await.ok_or_else (|| anyhow::anyhow! ("Relay server didn't open a bi stream"))??;
@ -37,7 +37,7 @@ async fn main () -> anyhow::Result <()> {
// TODO: Auth stuff
debug! ("Connecting to TCP end server");
debug! ("Started PTTH connection");
let stream = TcpStream::connect ("127.0.0.1:30382").await?;
let (local_recv, local_send) = stream.into_split ();
@ -46,7 +46,7 @@ async fn main () -> anyhow::Result <()> {
relay_send.write_all (&resp_buf).await?;
relay_send.write_all (&resp_buf).await?;
debug! ("Relaying bytes...");
trace! ("Relaying bytes...");
let ptth_conn = PtthNewConnection {
local_send,
@ -90,7 +90,7 @@ impl PtthNewConnection {
let mut buf = vec! [0u8; 65_536];
while let Some (bytes_read) = relay_recv.read (&mut buf).await? {
let buf_slice = &buf [0..bytes_read];
debug! ("Uplink relaying {} bytes", bytes_read);
trace! ("Uplink relaying {} bytes", bytes_read);
local_send.write_all (buf_slice).await?;
}
@ -109,7 +109,7 @@ impl PtthNewConnection {
break;
}
let buf_slice = &buf [0..bytes_read];
debug! ("Downlink relaying {} bytes", bytes_read);
trace! ("Downlink relaying {} bytes", bytes_read);
relay_send.write_all (buf_slice).await?;
}

View File

@ -72,11 +72,11 @@ impl PtthNewConnection {
break;
}
let buf_slice = &buf [0..bytes_read];
debug! ("Uplink relaying {} bytes", bytes_read);
trace! ("Uplink relaying {} bytes", bytes_read);
server_send.write_all (buf_slice).await?;
}
debug! ("Uplink closed");
trace! ("Uplink closed");
Ok::<_, anyhow::Error> (())
});
@ -87,11 +87,11 @@ impl PtthNewConnection {
let mut buf = vec! [0u8; 65_536];
while let Some (bytes_read) = server_recv.read (&mut buf).await? {
let buf_slice = &buf [0..bytes_read];
debug! ("Downlink relaying {} bytes", bytes_read);
trace! ("Downlink relaying {} bytes", bytes_read);
client_send.write_all (buf_slice).await?;
}
debug! ("Downlink closed");
trace! ("Downlink closed");
Ok::<_, anyhow::Error> (())
});
@ -161,6 +161,8 @@ async fn handle_p2_connection (
let relay_state = Arc::clone (&relay_state);
tokio::spawn (async move {
debug! ("Request started for P2");
let mut req_buf = [0u8; 4];
client_recv.read_exact (&mut req_buf).await?;
@ -191,7 +193,7 @@ async fn handle_request_p2_to_p4 (
client_recv: quinn::RecvStream,
) -> anyhow::Result <()>
{
debug! ("P2 {} wants to connect to P4 {}", client_id, server_id);
trace! ("P2 {} wants to connect to P4 {}", client_id, server_id);
// TODO: Auth checks
@ -261,7 +263,7 @@ async fn handle_p4_connection (
bail! ("P4 rejected request from {}", client_id);
}
debug! ("Relaying bytes...");
trace! ("Relaying bytes...");
let ptth_conn = PtthNewConnection {
client_send,

View File

@ -21,6 +21,7 @@ pub use tracing::{
debug,
error,
info,
trace,
warn,
};