Skip to content

Commit 6e85e30

Browse files
authored
Linux IPv6 routes handling fix (#126)
1 parent 50d8f12 commit 6e85e30

6 files changed

Lines changed: 34 additions & 26 deletions

File tree

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "defguard_wireguard_rs"
3-
version = "0.9.3"
3+
version = "0.9.4"
44
edition = "2024"
55
rust-version = "1.87"
66
description = "A unified multi-platform high-level API for managing WireGuard interfaces"

examples/userspace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn pause() {
1414
let mut stdout = stdout();
1515
stdout.write_all(b"Press Enter to continue...").unwrap();
1616
stdout.flush().unwrap();
17-
stdin().read(&mut [0]).unwrap();
17+
stdin().read_exact(&mut [0]).unwrap();
1818
}
1919

2020
fn main() -> Result<(), Box<dyn std::error::Error>> {

flake.lock

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

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
};
2626
rustToolchain = pkgs.rust-bin.stable.latest.default.override {
2727
extensions = ["rust-analyzer" "rust-src" "rustfmt" "clippy"];
28-
targets = ["x86_64-unknown-linux-gnu" "armv7-unknown-linux-gnueabihf" "aarch64-unknown-linux-gnu" "x86_64-unknown-freebsd"];
28+
targets = ["x86_64-unknown-linux-gnu" "armv7-unknown-linux-gnueabihf" "aarch64-unknown-linux-gnu" "x86_64-unknown-freebsd" "x86_64-apple-darwin" "x86_64-pc-windows-gnu"];
2929
};
3030
# define shared build inputs
3131
nativeBuildInputs = with pkgs; [rustToolchain pkg-config];

src/utils.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,12 +356,20 @@ pub(crate) fn add_peer_routing(
356356
}
357357
}
358358
if let Some(default_route) = default_routes.1 {
359-
setup_default_route(ifname, default_route)?;
359+
if let Err(err) = setup_default_route(ifname, default_route) {
360+
warn!("Failed to setup IPv6 default route for interface {ifname}: {err}.");
361+
}
360362
} else {
361363
for allowed_ip in allowed_ips.1 {
362364
debug!("Adding a route for allowed IPv6: {allowed_ip}");
363-
netlink::add_route(ifname, allowed_ip, None)?;
364-
debug!("Route added for allowed IPv6: {allowed_ip}");
365+
if let Err(err) = netlink::add_route(ifname, allowed_ip, None) {
366+
warn!(
367+
"Failed to add route for allowed IPv6 {allowed_ip} \
368+
on interface {ifname}: {err}."
369+
);
370+
} else {
371+
debug!("Route added for allowed IPv6: {allowed_ip}");
372+
}
365373
}
366374
}
367375
debug!("Peers routing added successfully");

0 commit comments

Comments
 (0)