Skip to content

Commit d4f0058

Browse files
committed
Fix Linux code
1 parent 7a40fab commit d4f0058

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

src/wgapi_linux.rs

+12-14
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
netlink,
@@ -50,17 +50,15 @@ impl WireguardInterfaceApi for WGApi<Kernel> {
5050
self.ifname
5151
);
5252

53-
// assign IP address to interface
54-
debug!(
55-
"Assigning address {} to interface {}",
56-
config.address, self.ifname
57-
);
58-
let address = IpAddrMask::from_str(&config.address)?;
59-
self.assign_address(&address)?;
60-
debug!(
61-
"Address {} assigned to interface {} successfully",
62-
config.address, self.ifname
63-
);
53+
// Assign IP addresses to the interface.
54+
for address in &config.addresses {
55+
debug!("Assigning address {address} to interface {}", self.ifname);
56+
self.assign_address(&address)?;
57+
debug!(
58+
"Address {address} assigned to interface {} successfully",
59+
self.ifname
60+
);
61+
}
6462

6563
// configure interface
6664
debug!(
@@ -88,8 +86,8 @@ impl WireguardInterfaceApi for WGApi<Kernel> {
8886
}
8987

9088
info!(
91-
"Interface {} has been successfully configured. It has been assigned the following address: {}",
92-
self.ifname, address
89+
"Interface {} has been successfully configured.",
90+
self.ifname
9391
);
9492
debug!(
9593
"Interface {} configured with config: {config:?}",

0 commit comments

Comments
 (0)