diff options
| author | David Lönnhager <david.l@mullvad.net> | 2024-03-12 13:13:01 +0100 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2024-03-13 17:51:14 +0100 |
| commit | 2745f3483ccefcc08a317a2127727ea9159f5986 (patch) | |
| tree | 6435d9d05c136970a2d70a2cd09397cff01b39cf | |
| parent | 3f0691cf8b1ca9d8fbb988d3d81fcfe927a305b8 (diff) | |
| download | mullvadvpn-2745f3483ccefcc08a317a2127727ea9159f5986.tar.xz mullvadvpn-2745f3483ccefcc08a317a2127727ea9159f5986.zip | |
Stop connectivity monitor when stats map is empty
This occurs when the WireGuard device is closed unexpectedly
| -rw-r--r-- | talpid-wireguard/src/connectivity_check.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/talpid-wireguard/src/connectivity_check.rs b/talpid-wireguard/src/connectivity_check.rs index a515ff5c6b..e820a3eb73 100644 --- a/talpid-wireguard/src/connectivity_check.rs +++ b/talpid-wireguard/src/connectivity_check.rs @@ -217,7 +217,14 @@ impl ConnectivityMonitor { .lock() .ok()? .as_ref() - .map(|tunnel| tunnel.get_tunnel_stats().map_err(Error::ConfigReadError)) + .and_then(|tunnel| match tunnel.get_tunnel_stats() { + Ok(stats) if stats.is_empty() => { + log::error!("Tunnel unexpectedly shut down"); + None + } + Ok(stats) => Some(Ok(stats)), + Err(error) => Some(Err(Error::ConfigReadError(error))), + }) } fn maybe_send_ping(&mut self, now: Instant) -> Result<(), Error> { |
