Skip to content

Commit

Permalink
Fix build error on non-Linux platform
Browse files Browse the repository at this point in the history
  • Loading branch information
sorz committed Mar 3, 2023
1 parent 222e5e3 commit ed691d9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,18 @@ impl NewClient {
pub async fn from_socket(mut left: TcpStream, list: ServerList) -> io::Result<Self> {
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<SocketAddr> = None;

let dest = if let Some(dest) = dest {
debug!(?dest, "Retrived destination via NAT info");
Expand Down

0 comments on commit ed691d9

Please sign in to comment.