fix(rust/gui-client/windows): read DNS servers before starting connlib (#6455)

Closes #6453

---------

Signed-off-by: Reactor Scram <ReactorScram@users.noreply.github.com>
Co-authored-by: Jamil <jamilbk@users.noreply.github.com>
This commit is contained in:
Reactor Scram
2024-08-27 13:49:41 -05:00
committed by GitHub
parent 2b030d801d
commit 2726e1dc00
2 changed files with 7 additions and 2 deletions

View File

@@ -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;
};

View File

@@ -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(())