Skip to content

Commit

Permalink
Log errors establishing upstream connection
Browse files Browse the repository at this point in the history
The result bubbled up to tokio::spawn() wasn't actually being reported anywhere.
  • Loading branch information
mqudsi committed Aug 28, 2023
1 parent ca67fd3 commit 84ed909
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -185,8 +191,7 @@ async fn forward(bind_ip: &str, local_port: i32, remote: &str) -> Result<(), Box
}
};

let r: Result<(), BoxedError> = Ok(());
r
()
});
}
}

0 comments on commit 84ed909

Please sign in to comment.