Skip to content

Commit b14bdb8

Browse files
committed
Fix FreeBSD build
1 parent 74dafcb commit b14bdb8

File tree

3 files changed

+35
-31
lines changed

3 files changed

+35
-31
lines changed

Cargo.lock

+23-16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/netlink.rs

+1
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ where
225225
}
226226

227227
/// Create WireGuard interface.
228+
/// Note: maximum 15 characters for `ifname`.
228229
pub(crate) fn create_interface(ifname: &str) -> NetlinkResult<()> {
229230
let mut message = LinkMessage::default();
230231
message.header.flags = LinkFlags::Up;

src/wgapi_freebsd.rs

+11-15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{net::IpAddr, str::FromStr};
1+
use std::net::IpAddr;
22

33
use crate::{
44
bsd,
@@ -14,7 +14,7 @@ use crate::{
1414
impl WireguardInterfaceApi for WGApi<Kernel> {
1515
/// Creates a WireGuard network interface.
1616
fn create_interface(&self) -> Result<(), WireguardInterfaceError> {
17-
bsd::load_wireguard_kernel_module();
17+
let _ = bsd::load_wireguard_kernel_module();
1818
debug!("Creating interface {}", &self.ifname);
1919
bsd::create_interface(&self.ifname)?;
2020
debug!("Interface {} created successfully", &self.ifname);
@@ -64,17 +64,11 @@ impl WireguardInterfaceApi for WGApi<Kernel> {
6464
self.ifname
6565
);
6666

67-
// assign IP address to interface
68-
debug!(
69-
"Parsing address {} for interface {}",
70-
config.address, self.ifname
71-
);
72-
let address = IpAddrMask::from_str(&config.address)?;
73-
debug!(
74-
"Address {} parsed successfully for interface {}",
75-
config.address, self.ifname
76-
);
77-
self.assign_address(&address)?;
67+
// Assign IP address to the interface.
68+
for address in &config.addresses {
69+
self.assign_address(address)?;
70+
}
71+
7872
// configure interface
7973
debug!(
8074
"Applying the WireGuard host configuration for interface {}",
@@ -99,13 +93,15 @@ impl WireguardInterfaceApi for WGApi<Kernel> {
9993
}
10094

10195
info!(
102-
"Interface {} has been successfully configured. It has been assigned the following address: {}",
103-
self.ifname, address
96+
"Interface {} has been successfully configured. \
97+
It has been assigned the following addresses: {:?}",
98+
self.ifname, config.addresses
10499
);
105100
debug!(
106101
"Interface {} configured with config: {config:?}",
107102
self.ifname
108103
);
104+
109105
Ok(())
110106
}
111107

0 commit comments

Comments
 (0)