From 9f474cb71ecfa77f9ca30890e84263ecf5b8a2ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20L=C3=B6nnhager?= Date: Tue, 17 Dec 2024 10:05:08 +0100 Subject: [PATCH] Do not drop conn checker when updating tun without toggling multihop --- talpid-wireguard/src/wireguard_go/mod.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/talpid-wireguard/src/wireguard_go/mod.rs b/talpid-wireguard/src/wireguard_go/mod.rs index 39b23a185aeb..b91f3c464a4c 100644 --- a/talpid-wireguard/src/wireguard_go/mod.rs +++ b/talpid-wireguard/src/wireguard_go/mod.rs @@ -106,17 +106,18 @@ impl WgGoTunnel { } } - pub fn set_config(mut self, config: &Config) -> Result { - let connectivity_checker = self - .take_checker() - .expect("connectivity checker unexpectedly dropped"); + pub fn set_config(self, config: &Config) -> Result { let state = self.as_state(); let log_path = state._logging_context.path.clone(); let tun_provider = Arc::clone(&state.tun_provider); let routes = config.get_tunnel_destinations(); match self { - WgGoTunnel::Multihop(state) if !config.is_multihop() => { + WgGoTunnel::Multihop(mut state) if !config.is_multihop() => { + let connectivity_checker = state + .connectivity_checker + .take() + .expect("connectivity checker unexpectedly dropped"); state.stop()?; Self::start_tunnel( config, @@ -126,7 +127,11 @@ impl WgGoTunnel { connectivity_checker, ) } - WgGoTunnel::Singlehop(state) if config.is_multihop() => { + WgGoTunnel::Singlehop(mut state) if config.is_multihop() => { + let connectivity_checker = state + .connectivity_checker + .take() + .expect("connectivity checker unexpectedly dropped"); state.stop()?; Self::start_multihop_tunnel( config,