From 86910f477dc1a3b3d07349d045446094a98ca168 Mon Sep 17 00:00:00 2001 From: Reactor Scram Date: Tue, 24 Sep 2024 09:13:01 -0500 Subject: [PATCH] fix(rust/gui-client/auth): destroy the connlib session on disconnect (#6795) Closes #6791 We weren't closing the connlib session immediately when we get `on_disconnect`, this patch fixes that. This passes the manual test established in #6792. I also cycled through sign-in, close, open, sign-out, and it looks fine. --------- Signed-off-by: Reactor Scram --- rust/headless-client/src/ipc_service.rs | 22 ++++++++++++++-------- website/src/components/Changelog/GUI.tsx | 3 +++ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/rust/headless-client/src/ipc_service.rs b/rust/headless-client/src/ipc_service.rs index 77933e7ad..8fe27afdc 100644 --- a/rust/headless-client/src/ipc_service.rs +++ b/rust/headless-client/src/ipc_service.rs @@ -375,14 +375,20 @@ impl<'a> Handler<'a> { ConnlibMsg::OnDisconnect { error_msg, is_authentication_error, - } => self - .ipc_tx - .send(&ServerMsg::OnDisconnect { - error_msg, - is_authentication_error, - }) - .await - .context("Error while sending IPC message `OnDisconnect`")?, + } => { + if let Some(session) = self.session.take() { + // Identical to dropping, but looks nicer + session.connlib.disconnect(); + } + self.dns_controller.deactivate()?; + self.ipc_tx + .send(&ServerMsg::OnDisconnect { + error_msg, + is_authentication_error, + }) + .await + .context("Error while sending IPC message `OnDisconnect`")? + } ConnlibMsg::OnSetInterfaceConfig { ipv4, ipv6, dns } => { self.tun_device.set_ips(ipv4, ipv6).await?; self.dns_controller.set_dns(dns).await?; diff --git a/website/src/components/Changelog/GUI.tsx b/website/src/components/Changelog/GUI.tsx index 972cfcf04..f89d75f42 100644 --- a/website/src/components/Changelog/GUI.tsx +++ b/website/src/components/Changelog/GUI.tsx @@ -19,6 +19,9 @@ export default function GUI({ title }: { title: string }) { Fixes a bug where the Linux Clients didn't work on ZFS filesystems + + Fixes a bug where auto-sign-in with an expired token would cause a "Couldn't send Disconnect" error message. +