diff --git a/Cargo.toml b/Cargo.toml index 24ebc64..bb61ca9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,11 +42,6 @@ url = "2" [target.'cfg(target_os="linux")'.dependencies] serde = { version = "1", features = ["derive"] } bincode = "1" -nix = { version = "0.29", default-features = false, features = [ - "fs", - "socket", - "uio", -] } [target.'cfg(target_os="android")'.dependencies] android_logger = "0.14" @@ -54,6 +49,11 @@ jni = { version = "0.21", default-features = false } [target.'cfg(unix)'.dependencies] daemonize = "0.5" +nix = { version = "0.29", default-features = false, features = [ + "fs", + "socket", + "uio", +] } [target.'cfg(target_os = "windows")'.dependencies] windows-service = "0.7" diff --git a/src/bin/udpgw_server.rs b/src/bin/udpgw_server.rs index 666c8a8..6e96dc2 100644 --- a/src/bin/udpgw_server.rs +++ b/src/bin/udpgw_server.rs @@ -184,7 +184,7 @@ async fn process_udp(addr: SocketAddr, udp_timeout: u64, tx: Sender>, co std::net::UdpSocket::bind("0.0.0.0:0")? }; std_sock.set_nonblocking(true)?; - #[cfg(target_os = "linux")] + #[cfg(unix)] nix::sys::socket::setsockopt(&std_sock, nix::sys::socket::sockopt::ReuseAddr, &true)?; let socket = UdpSocket::from_std(std_sock)?; socket.send_to(&con.data, &con.server_addr).await?; diff --git a/src/error.rs b/src/error.rs index f460b62..755ee0c 100644 --- a/src/error.rs +++ b/src/error.rs @@ -6,7 +6,7 @@ pub enum Error { #[error(transparent)] Io(#[from] std::io::Error), - #[cfg(target_os = "linux")] + #[cfg(unix)] #[error("nix::errno::Errno {0:?}")] NixErrno(#[from] nix::errno::Errno),