Skip to content

Commit 136855e

Browse files
authored
Fix compilation on windows (#103)
1 parent c9e6f7d commit 136855e

File tree

5 files changed

+24
-28
lines changed

5 files changed

+24
-28
lines changed

Cargo.lock

Lines changed: 16 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ keywords = ["wireguard", "network", "vpn"]
1212
categories = ["network-programming"]
1313

1414
[dependencies]
15-
boringtun = { path = "boringtun/boringtun", default-features = false, features = ["device"] }
1615
base64 = "0.22"
1716
log = "0.4"
1817
serde = { version = "1.0", features = ["derive"], optional = true }
@@ -26,6 +25,9 @@ tracing = "0.1"
2625
tracing-subscriber = "0.3"
2726

2827
[target.'cfg(any(target_os = "freebsd", target_os = "macos", target_os = "netbsd"))'.dependencies]
28+
boringtun = { path = "boringtun/boringtun", default-features = false, features = [
29+
"device",
30+
] }
2931
libc = { version = "0.2", default-features = false }
3032
nix = { version = "0.30", features = ["ioctl", "socket"] }
3133

src/error.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ pub enum WireguardInterfaceError {
4141
ServiceRemovalFailed(String),
4242
#[error("Socket is closed: {0}")]
4343
SocketClosed(String),
44+
#[cfg(any(target_os = "freebsd", target_os = "macos", target_os = "netbsd"))]
4445
#[error("BoringTun {0}")]
4546
BoringTun(#[from] boringtun::device::Error),
4647
}

src/wgapi.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! Shared multi-platform management API abstraction
22
use std::marker::PhantomData;
33

4+
#[cfg(any(target_os = "freebsd", target_os = "macos", target_os = "netbsd"))]
45
use boringtun::device::DeviceHandle;
56

67
#[cfg(feature = "check_dependencies")]
@@ -16,6 +17,7 @@ pub struct Userspace;
1617
/// to detect the correct API implementation for most common platforms.
1718
pub struct WGApi<API = Kernel> {
1819
pub(super) ifname: String,
20+
#[cfg(any(target_os = "freebsd", target_os = "macos", target_os = "netbsd"))]
1921
pub(super) device_handle: Option<DeviceHandle>,
2022
pub(super) _api: PhantomData<API>,
2123
}
@@ -27,6 +29,7 @@ impl<API> WGApi<API> {
2729
check_external_dependencies()?;
2830
Ok(WGApi {
2931
ifname: ifname.into(),
32+
#[cfg(any(target_os = "freebsd", target_os = "macos", target_os = "netbsd"))]
3033
device_handle: None,
3134
_api: PhantomData,
3235
})

src/wgapi_windows.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use crate::{
2020

2121
/// Manages interfaces created with Windows kernel using https://git.zx2c4.com/wireguard-nt.
2222
impl WireguardInterfaceApi for WGApi<Kernel> {
23-
fn create_interface(&self) -> Result<(), WireguardInterfaceError> {
23+
fn create_interface(&mut self) -> Result<(), WireguardInterfaceError> {
2424
info!("Opening/creating interface {}", self.ifname);
2525
Ok(())
2626
}

0 commit comments

Comments
 (0)