diff --git a/crates/shadowsocks-service/src/local/net/udp/association.rs b/crates/shadowsocks-service/src/local/net/udp/association.rs index 967426c26a68..829900b6b038 100644 --- a/crates/shadowsocks-service/src/local/net/udp/association.rs +++ b/crates/shadowsocks-service/src/local/net/udp/association.rs @@ -549,10 +549,16 @@ where let mut buffer = [0u8; MAXIMUM_UDP_PAYLOAD_SIZE]; loop { let (n, addr) = match outbound.recv(&mut buffer).await { - Ok(n) => { + Ok((n, addr)) => { + trace!( + "udp relay {} <- {} (proxied) received {} bytes", + self.peer_addr, + addr, + n + ); // Keep association alive in map let _ = self.assoc_map.lock().await.get(&self.peer_addr); - n + (n, addr) } Err(err) => { // Socket that connected to remote server returns an error, it should be ECONNREFUSED in most cases. @@ -575,13 +581,18 @@ where // Send back to client if let Err(err) = self.respond_writer.send_to(self.peer_addr, &addr, data).await { warn!( - "udp failed to send back to client {}, from target {}, error: {}", + "udp failed to send back to client {}, from target {} (proxied), error: {}", self.peer_addr, addr, err ); continue; } - trace!("udp relay {} <- {} with {} bytes", self.peer_addr, addr, data.len()); + trace!( + "udp relay {} <- {} (proxied) with {} bytes", + self.peer_addr, + addr, + data.len() + ); } } @@ -589,10 +600,16 @@ where let mut buffer = [0u8; MAXIMUM_UDP_PAYLOAD_SIZE]; loop { let (n, addr) = match outbound.recv_from(&mut buffer).await { - Ok(n) => { + Ok((n, addr)) => { + trace!( + "udp relay {} <- {} (bypassed) received {} bytes", + self.peer_addr, + addr, + n + ); // Keep association alive in map let _ = self.assoc_map.lock().await.get(&self.peer_addr); - n + (n, addr) } Err(err) => { error!( @@ -610,13 +627,18 @@ where // Send back to client if let Err(err) = self.respond_writer.send_to(self.peer_addr, &addr, data).await { warn!( - "udp failed to send back to client {}, from target {}, error: {}", + "udp failed to send back to client {}, from target {} (bypassed), error: {}", self.peer_addr, addr, err ); continue; } - trace!("udp relay {} <- {} with {} bytes", self.peer_addr, addr, data.len()); + trace!( + "udp relay {} <- {} (bypassed) with {} bytes", + self.peer_addr, + addr, + data.len() + ); } } } diff --git a/crates/shadowsocks-service/src/local/tunnel/udprelay.rs b/crates/shadowsocks-service/src/local/tunnel/udprelay.rs index 5d50c18a55c9..86144b043f4d 100644 --- a/crates/shadowsocks-service/src/local/tunnel/udprelay.rs +++ b/crates/shadowsocks-service/src/local/tunnel/udprelay.rs @@ -370,8 +370,9 @@ impl UdpAssociationContext { async fn copy_proxied_r2l(self: Arc, outbound: Arc) -> io::Result<()> { let mut buffer = [0u8; MAXIMUM_UDP_PAYLOAD_SIZE]; loop { - let (n, _) = match outbound.recv(&mut buffer).await { - Ok(n) => { + let n = match outbound.recv(&mut buffer).await { + Ok((n, addr)) => { + trace!("udp relay {} <- {} received {} bytes", self.peer_addr, addr, n); // Keep association alive in map let _ = self.assoc_map.lock().await.get(&self.peer_addr); n diff --git a/crates/shadowsocks-service/src/server/udprelay.rs b/crates/shadowsocks-service/src/server/udprelay.rs index 0664956fe9c1..85b75536043f 100644 --- a/crates/shadowsocks-service/src/server/udprelay.rs +++ b/crates/shadowsocks-service/src/server/udprelay.rs @@ -414,10 +414,11 @@ impl UdpAssociationContext { let mut buffer = [0u8; MAXIMUM_UDP_PAYLOAD_SIZE]; loop { let (n, addr) = match outbound.recv_from(&mut buffer).await { - Ok(n) => { + Ok((n, addr)) => { + trace!("udp relay {} <- {} received {} bytes", self.peer_addr, addr, n); // Keep association alive in map let _ = self.assoc_map.lock().await.get(&self.peer_addr); - n + (n, addr) } Err(err) => { error!(