diff --git a/Cargo.lock b/Cargo.lock index b1c396c..eb6a69f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -234,9 +234,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.39" +version = "1.2.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1354349954c6fc9cb0deab020f27f783cf0b604e8bb754dc4658ecf0d29c35f" +checksum = "e1d05d92f4b1fd76aad469d46cdd858ca761576082cd37df81416691e50199fb" dependencies = [ "find-msvc-tools", "shlex", @@ -451,7 +451,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.61.1", + "windows-sys 0.60.2", ] [[package]] @@ -468,9 +468,9 @@ checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" [[package]] name = "find-msvc-tools" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ced73b1dacfc750a6db6c0a0c3a3853c8b41997e2e2c563dc90804ae6867959" +checksum = "0399f9d26e5191ce32c498bebd31e7a3ceabc2745f0ac54af3f335126c3f24b3" [[package]] name = "fs-err" @@ -655,11 +655,10 @@ checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039" [[package]] name = "lock_api" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" dependencies = [ - "autocfg", "scopeguard", ] @@ -806,9 +805,9 @@ checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" [[package]] name = "parking_lot" -version = "0.12.4" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70d58bf43669b5795d1576d0641cfb6fbb2057bf629506267a92807158584a13" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" dependencies = [ "lock_api", "parking_lot_core", @@ -816,15 +815,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.11" +version = "0.9.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-targets 0.52.6", + "windows-link", ] [[package]] @@ -918,9 +917,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.17" +version = "0.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5407465600fb0548f1442edf71dd20683c6ed326200ace4b1ef0763521bb3b77" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" dependencies = [ "bitflags", ] @@ -993,7 +992,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys 0.61.1", + "windows-sys 0.60.2", ] [[package]] @@ -1172,7 +1171,7 @@ dependencies = [ "getrandom 0.3.3", "once_cell", "rustix", - "windows-sys 0.61.1", + "windows-sys 0.60.2", ] [[package]] @@ -1524,15 +1523,6 @@ dependencies = [ "windows-targets 0.53.4", ] -[[package]] -name = "windows-sys" -version = "0.61.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f109e41dd4a3c848907eb83d5a42ea98b3769495597450cf6d153507b166f0f" -dependencies = [ - "windows-link", -] - [[package]] name = "windows-targets" version = "0.52.6" diff --git a/Cargo.toml b/Cargo.toml index d324180..180befb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,6 @@ keywords = ["wireguard", "network", "vpn"] categories = ["network-programming"] [dependencies] -boringtun = { path = "boringtun/boringtun", default-features = false, features = ["device"] } base64 = "0.22" log = "0.4" serde = { version = "1.0", features = ["derive"], optional = true } @@ -26,6 +25,9 @@ tracing = "0.1" tracing-subscriber = "0.3" [target.'cfg(any(target_os = "freebsd", target_os = "macos", target_os = "netbsd"))'.dependencies] +boringtun = { path = "boringtun/boringtun", default-features = false, features = [ + "device", +] } libc = { version = "0.2", default-features = false } nix = { version = "0.30", features = ["ioctl", "socket"] } diff --git a/src/error.rs b/src/error.rs index ac8f4dc..64775d0 100644 --- a/src/error.rs +++ b/src/error.rs @@ -41,6 +41,7 @@ pub enum WireguardInterfaceError { ServiceRemovalFailed(String), #[error("Socket is closed: {0}")] SocketClosed(String), + #[cfg(any(target_os = "freebsd", target_os = "macos", target_os = "netbsd"))] #[error("BoringTun {0}")] BoringTun(#[from] boringtun::device::Error), } diff --git a/src/wgapi.rs b/src/wgapi.rs index b433ff4..55b5e15 100644 --- a/src/wgapi.rs +++ b/src/wgapi.rs @@ -1,6 +1,7 @@ //! Shared multi-platform management API abstraction use std::marker::PhantomData; +#[cfg(any(target_os = "freebsd", target_os = "macos", target_os = "netbsd"))] use boringtun::device::DeviceHandle; #[cfg(feature = "check_dependencies")] @@ -16,6 +17,7 @@ pub struct Userspace; /// to detect the correct API implementation for most common platforms. pub struct WGApi { pub(super) ifname: String, + #[cfg(any(target_os = "freebsd", target_os = "macos", target_os = "netbsd"))] pub(super) device_handle: Option, pub(super) _api: PhantomData, } @@ -27,6 +29,7 @@ impl WGApi { check_external_dependencies()?; Ok(WGApi { ifname: ifname.into(), + #[cfg(any(target_os = "freebsd", target_os = "macos", target_os = "netbsd"))] device_handle: None, _api: PhantomData, }) diff --git a/src/wgapi_windows.rs b/src/wgapi_windows.rs index ccd67af..4d36e72 100644 --- a/src/wgapi_windows.rs +++ b/src/wgapi_windows.rs @@ -20,7 +20,7 @@ use crate::{ /// Manages interfaces created with Windows kernel using https://git.zx2c4.com/wireguard-nt. impl WireguardInterfaceApi for WGApi { - fn create_interface(&self) -> Result<(), WireguardInterfaceError> { + fn create_interface(&mut self) -> Result<(), WireguardInterfaceError> { info!("Opening/creating interface {}", self.ifname); Ok(()) }