diff --git a/src/main.rs b/src/main.rs index ed8a9cb..d52445f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -773,7 +773,7 @@ async fn main() { .map_ok(move |stream| { // In TProxy mode local destination is the final ip:port destination let (host, port) = to_host_port(stream.local_addr().unwrap()); - (tokio::io::split(stream), (LocalProtocol::Udp { timeout: timeout }, host, port)) + (tokio::io::split(stream), (LocalProtocol::Udp { timeout }, host, port)) }); tokio::spawn(async move { @@ -789,7 +789,7 @@ async fn main() { LocalProtocol::Udp { timeout } => { let (host, port) = tunnel.remote.clone(); let timeout = *timeout; - let server = udp::run_server(tunnel.local, timeout.clone(), |_| Ok(()), |s| Ok(s.clone())) + let server = udp::run_server(tunnel.local, timeout, |_| Ok(()), |s| Ok(s.clone())) .await .unwrap_or_else(|err| panic!("Cannot start UDP server on {}: {}", tunnel.local, err)) .map_err(anyhow::Error::new) diff --git a/src/socks5_udp.rs b/src/socks5_udp.rs index d8e02dd..38d40c4 100644 --- a/src/socks5_udp.rs +++ b/src/socks5_udp.rs @@ -241,7 +241,7 @@ pub async fn run_server( match server.peers.get(&destination_addr) { Some(io) => { - if let Err(_) = io.sender.send(data).await { + if io.sender.send(data).await.is_err() { server.peers.remove(&destination_addr); } }