diff --git a/phantun/src/bin/client.rs b/phantun/src/bin/client.rs index 2219953..e18d7a1 100644 --- a/phantun/src/bin/client.rs +++ b/phantun/src/bin/client.rs @@ -245,13 +245,12 @@ async fn main() -> io::Result<()> { res = sock.recv(&mut buf_tcp) => { match res { Some(size) => { - if size > 0 { - if let Err(e) = udp_sock.send(&buf_tcp[..size]).await { + if size > 0 + && let Err(e) = udp_sock.send(&buf_tcp[..size]).await { error!("Unable to send UDP packet to {}: {}, closing connection", e, addr); quit.cancel(); return; } - } }, None => { debug!("removed fake TCP socket from connections table"); diff --git a/phantun/src/bin/server.rs b/phantun/src/bin/server.rs index 5160d0e..960fb99 100644 --- a/phantun/src/bin/server.rs +++ b/phantun/src/bin/server.rs @@ -219,13 +219,12 @@ async fn main() -> io::Result<()> { res = sock.recv(&mut buf_tcp) => { match res { Some(size) => { - if size > 0 { - if let Err(e) = udp_sock.send(&buf_tcp[..size]).await { + if size > 0 + && let Err(e) = udp_sock.send(&buf_tcp[..size]).await { error!("Unable to send UDP packet to {}: {}, closing connection", e, remote_addr); quit.cancel(); return; } - } }, None => { quit.cancel();