Log errors establishing upstream connection

The result bubbled up to tokio::spawn() wasn't actually being reported anywhere.
This commit is contained in:
Mahmoud Al-Qudsi 2023-08-28 17:57:05 -05:00
parent ca67fd31ca
commit 84ed909836
1 changed files with 8 additions and 3 deletions

View File

@ -137,7 +137,13 @@ async fn forward(bind_ip: &str, local_port: i32, remote: &str) -> Result<(), Box
println!("New connection from {}", client_addr);
// Establish connection to upstream for each incoming client connection
let mut remote = TcpStream::connect(remote.as_str()).await?;
let mut remote = match TcpStream::connect(remote.as_str()).await {
Ok(result) => result,
Err(e) => {
eprintln!("Error establishing upstream connection: {e}");
return;
}
};
let (mut client_read, mut client_write) = client.split();
let (mut remote_read, mut remote_write) = remote.split();
@ -185,8 +191,7 @@ async fn forward(bind_ip: &str, local_port: i32, remote: &str) -> Result<(), Box
}
};
let r: Result<(), BoxedError> = Ok(());
r
()
});
}
}