We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4670326 commit 815604cCopy full SHA for 815604c
src/server/mod.rs
@@ -114,9 +114,18 @@ async fn server(config: &Properties) -> Result<(), Error> {
114
info!("Proxy to: {}", config.proxy);
115
116
while let Ok((stream, peer)) = server.accept().await {
117
- info!("Client connected: {}", peer);
118
- let tcp = TcpStream::connect(&config.proxy).await.unwrap();
119
- tokio::spawn(accept_connection(stream, tcp));
+ let dest = config.proxy.clone();
+ tokio::spawn(async move {
+ info!("Client connected: {}", peer);
120
+ let tcp = match TcpStream::connect(dest).await {
121
+ Ok(tcp) => tcp,
122
+ Err(e) => {
123
+ error!("Client rejected: {} cause {}", peer, e);
124
+ return;
125
+ }
126
+ };
127
+ accept_connection(stream, tcp).await;
128
+ });
129
}
130
131
Ok(())
0 commit comments