From 94d9a14c815a40699cd9c08728f42598e7b249a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=A3rebe=20-=20Romain=20GERARD?= Date: Wed, 27 Mar 2024 08:25:46 +0100 Subject: [PATCH] fix: Avoid stopping accepting new connection on error --- src/tunnel/client.rs | 10 +++++++++- src/tunnel/server.rs | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/tunnel/client.rs b/src/tunnel/client.rs index d2fe3ec..ad459f9 100644 --- a/src/tunnel/client.rs +++ b/src/tunnel/client.rs @@ -63,7 +63,15 @@ where W: AsyncWrite + Send + 'static, { pin_mut!(incoming_cnx); - while let Some(Ok((cnx_stream, remote_addr))) = incoming_cnx.next().await { + while let Some(cnx) = incoming_cnx.next().await { + let (cnx_stream, remote_addr) = match cnx { + Ok((cnx_stream, remote_addr)) => (cnx_stream, remote_addr), + Err(err) => { + error!("Error accepting connection: {:?}", err); + continue; + } + }; + let request_id = Uuid::now_v7(); let span = span!( Level::INFO, diff --git a/src/tunnel/server.rs b/src/tunnel/server.rs index 109a545..158c46a 100644 --- a/src/tunnel/server.rs +++ b/src/tunnel/server.rs @@ -205,7 +205,7 @@ where None => break, Some(Err(err)) => { warn!("Error while listening for incoming connections {err:?}"); - break; + continue; } Some(Ok(cnx)) => { if tx.send_timeout(cnx, Duration::from_secs(30)).await.is_err() {