From ed691d988a793e069abe8e6765ed987d9c077ae3 Mon Sep 17 00:00:00 2001 From: Shell Chen Date: Fri, 3 Mar 2023 19:18:46 +0800 Subject: [PATCH] Fix build error on non-Linux platform --- Cargo.lock | 2 +- src/client/mod.rs | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9101338..798f5f8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -776,7 +776,7 @@ dependencies = [ [[package]] name = "moproxy" -version = "0.3.12" +version = "0.4.0" dependencies = [ "base64 0.21.0", "bytes", diff --git a/src/client/mod.rs b/src/client/mod.rs index 4ed4b72..ba6e970 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -139,19 +139,18 @@ impl NewClient { pub async fn from_socket(mut left: TcpStream, list: ServerList) -> io::Result { let src = left.peer_addr()?; let from_port = left.local_addr()?.port(); - let local = left.local_addr()?; // Try to get original destination before NAT #[cfg(target_os = "linux")] let dest = match left.get_original_dest()? { // Redirecting to itself is possible. Treat it as non-redirect. - Some(dest) if dest.normalize() != local.normalize() => Some(dest), + Some(dest) if dest.normalize() != left.local_addr()?.normalize() => Some(dest), _ => None, }; // No NAT supported #[cfg(not(target_os = "linux"))] - let dest = None; + let dest: Option = None; let dest = if let Some(dest) = dest { debug!(?dest, "Retrived destination via NAT info");