summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2023-06-27 16:23:42 +0200
committerDavid Lönnhager <david.l@mullvad.net>2023-06-28 11:37:41 +0200
commitcf3b1a13416e2d1c461ac7f5bd86ef05bd43f434 (patch)
tree671ceaf63018fc5769b974f7bc28218b0cb29fc7
parent3be50744ec5c1acf089692a9f4a7f77c3ecf2529 (diff)
downloadmullvadvpn-cf3b1a13416e2d1c461ac7f5bd86ef05bd43f434.tar.xz
mullvadvpn-cf3b1a13416e2d1c461ac7f5bd86ef05bd43f434.zip
Make it possible to use gateway or router as the custom WireGuard endpoint
-rw-r--r--talpid-routing/src/unix/macos/watch.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/talpid-routing/src/unix/macos/watch.rs b/talpid-routing/src/unix/macos/watch.rs
index 4cf1799276..d7fdd60f42 100644
--- a/talpid-routing/src/unix/macos/watch.rs
+++ b/talpid-routing/src/unix/macos/watch.rs
@@ -48,6 +48,16 @@ impl RoutingTable {
}
pub async fn add_route(&mut self, message: &RouteMessage) -> Result<()> {
+ if let Ok(destination) = message.destination_ip() {
+ if Some(destination.ip()) == message.gateway_ip() {
+ // Workaround that allows us to reach a wg peer on our router.
+ // If we don't do this, adding the route fails due to errno 49
+ // ("Can't assign requested address").
+ log::warn!("Ignoring route because the destination equals its gateway");
+ return Ok(());
+ }
+ }
+
let msg = self
.alter_routing_table(message, MessageType::RTM_ADD)
.await;