From 1288c2ed7c635c2ba41d2609ccf5a93073e0031f Mon Sep 17 00:00:00 2001 From: zonyitoo Date: Tue, 22 Dec 2020 23:53:06 +0800 Subject: [PATCH] ignore bind transparent ip error and continue receiving --- .../src/local/redir/udprelay/mod.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/shadowsocks-service/src/local/redir/udprelay/mod.rs b/crates/shadowsocks-service/src/local/redir/udprelay/mod.rs index f7da3b30..d7d225a3 100644 --- a/crates/shadowsocks-service/src/local/redir/udprelay/mod.rs +++ b/crates/shadowsocks-service/src/local/redir/udprelay/mod.rs @@ -489,7 +489,16 @@ impl UdpAssociationContext { // Create a socket binds to destination addr // This only works for systems that supports binding to non-local addresses - let inbound = UdpRedirSocket::bind(self.redir_ty, addr)?; + let inbound = match UdpRedirSocket::bind(self.redir_ty, addr) { + Ok(s) => s, + Err(err) => { + error!( + "failed to bind to dest {} for sending back to {}, error: {}", + addr, self.peer_addr, err + ); + continue; + } + }; // Send back to client if let Err(err) = inbound.send_to(data, self.peer_addr).await { @@ -497,6 +506,7 @@ impl UdpAssociationContext { "udp failed to send back to client {}, from target {}, error: {}", self.peer_addr, addr, err ); + continue; } trace!("udp relay {} <- {} with {} bytes", self.peer_addr, addr, data.len());