From 2726e1dc001bf779a320bc27908dd0f4ee9fa647 Mon Sep 17 00:00:00 2001 From: Reactor Scram Date: Tue, 27 Aug 2024 13:49:41 -0500 Subject: [PATCH] fix(rust/gui-client/windows): read DNS servers before starting connlib (#6455) Closes #6453 --------- Signed-off-by: Reactor Scram Co-authored-by: Jamil --- rust/connlib/tunnel/src/client.rs | 3 ++- rust/headless-client/src/ipc_service.rs | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/rust/connlib/tunnel/src/client.rs b/rust/connlib/tunnel/src/client.rs index 522283e74..65b4fa9f3 100644 --- a/rust/connlib/tunnel/src/client.rs +++ b/rust/connlib/tunnel/src/client.rs @@ -1119,7 +1119,8 @@ impl ClientState { fn update_dns_mapping(&mut self) { let Some(config) = &self.interface_config else { - tracing::debug!("Unable to update DNS servesr without interface configuration"); + // For the Tauri clients this can happen because it's called immediately after phoenix_channel's connect, before on_set_interface_config + tracing::debug!("Unable to update DNS servers without interface configuration"); return; }; diff --git a/rust/headless-client/src/ipc_service.rs b/rust/headless-client/src/ipc_service.rs index d8dd92fa0..f7af80714 100644 --- a/rust/headless-client/src/ipc_service.rs +++ b/rust/headless-client/src/ipc_service.rs @@ -492,13 +492,17 @@ impl<'a> Handler<'a> { ) .map_err(|e| Error::PortalConnection(e.to_string()))?; + // Read the resolvers before starting connlib, in case connlib's startup interferes. + let dns = self.dns_controller.system_resolvers(); let new_session = Session::connect(args, portal, tokio::runtime::Handle::current()); + // Call `set_dns` before `set_tun` so that the tunnel starts up with a valid list of resolvers. + tracing::debug!(?dns, "Calling `set_dns`..."); + new_session.set_dns(dns); let tun = self .tun_device .make_tun() .map_err(|e| Error::TunnelDevice(e.to_string()))?; new_session.set_tun(Box::new(tun)); - new_session.set_dns(self.dns_controller.system_resolvers()); self.connlib = Some(new_session); Ok(())