From c1da627650cfa949670a3abba038c0ce70502883 Mon Sep 17 00:00:00 2001 From: zonyitoo Date: Sun, 16 Jun 2024 18:46:12 +0800 Subject: [PATCH] chore(local-redir): Better code style --- .../src/local/redir/udprelay/mod.rs | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/crates/shadowsocks-service/src/local/redir/udprelay/mod.rs b/crates/shadowsocks-service/src/local/redir/udprelay/mod.rs index a28de664b3b3..f83db73cadf1 100644 --- a/crates/shadowsocks-service/src/local/redir/udprelay/mod.rs +++ b/crates/shadowsocks-service/src/local/redir/udprelay/mod.rs @@ -191,28 +191,28 @@ impl UdpInboundWrite for UdpRedirInboundWriter { } } - let send_result = inbound.send_to(data, peer_addr).await.map(|n| { - if n < data.len() { - warn!( - "udp redir send back data (actual: {} bytes, sent: {} bytes), remote: {}, peer: {}", + match inbound.send_to(data, peer_addr).await { + Ok(n) => { + if n < data.len() { + warn!( + "udp redir send back data (actual: {} bytes, sent: {} bytes), remote: {}, peer: {}", + n, + data.len(), + remote_addr, + peer_addr + ); + } + + trace!( + "udp redir send back data {} bytes, remote: {}, peer: {}, socket_opts: {:?}", n, - data.len(), remote_addr, - peer_addr + peer_addr, + self.socket_opts ); - } - trace!( - "udp redir send back data {} bytes, remote: {}, peer: {}, socket_opts: {:?}", - n, - remote_addr, - peer_addr, - self.socket_opts - ); - }); - - match send_result { - Ok(()) => return Ok(()), + return Ok(()); + } Err(err) => { match err.kind() { // Invalid Argument