summaryrefslogtreecommitdiffhomepage
path: root/talpid-wireguard/src
diff options
context:
space:
mode:
authorDavid Göransson <david.goransson@mullvad.net>2025-01-13 11:51:09 +0100
committerDavid Göransson <david.goransson@mullvad.net>2025-02-06 11:02:59 +0100
commit341c10ba38752bc36151b8998064e706f70d9ea6 (patch)
treeafb60c53e267eda0b033f346b64afd9035d7495a /talpid-wireguard/src
parent612aad8d8d2ae779a4e5e01e85b2848b4fc7de3c (diff)
downloadmullvadvpn-341c10ba38752bc36151b8998064e706f70d9ea6.tar.xz
mullvadvpn-341c10ba38752bc36151b8998064e706f70d9ea6.zip
Replace old waitForTunnelUp function
After invoking VpnService.establish() we will get a tunnel file descriptor that corresponds to the interface that was created. However, this has no guarantee of the routing table beeing up to date, and we might thus send traffic outside the tunnel. Previously this was done through looking at the tunFd to see that traffic is sent to verify that the routing table has changed. If no traffic is seen some traffic is induced to a random IP address to ensure traffic can be seen. This new implementation is slower but won't risk sending UDP traffic to a random public address at the internet.
Diffstat (limited to 'talpid-wireguard/src')
-rw-r--r--talpid-wireguard/src/lib.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/talpid-wireguard/src/lib.rs b/talpid-wireguard/src/lib.rs
index af8e2da79e..fe1a848e9a 100644
--- a/talpid-wireguard/src/lib.rs
+++ b/talpid-wireguard/src/lib.rs
@@ -403,7 +403,6 @@ impl WireguardMonitor {
let desired_mtu = get_desired_mtu(params);
let mut config =
Config::from_parameters(params, desired_mtu).map_err(Error::WireguardConfigError)?;
-
let (close_obfs_sender, close_obfs_listener) = sync_mpsc::channel();
// Start obfuscation server and patch the WireGuard config to point the endpoint to it.
let obfuscator = args
@@ -466,6 +465,13 @@ impl WireguardMonitor {
.on_event(TunnelEvent::InterfaceUp(metadata.clone(), allowed_traffic))
.await;
+ // Wait for routes to come up
+ args.route_manager
+ .wait_for_routes()
+ .await
+ .map_err(Error::SetupRoutingError)
+ .map_err(CloseMsg::SetupError)?;
+
if should_negotiate_ephemeral_peer {
let ephemeral_obfs_sender = close_obfs_sender.clone();