From 957b8f9aa6e09f1825cf89171a36fa44fd9cac84 Mon Sep 17 00:00:00 2001 From: Mathew-D Date: Sat, 9 May 2026 20:13:26 -0400 Subject: [PATCH] fix(vpn): Fixed the async connection issue in the VPN service --- src/dbus/network/network_service.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/dbus/network/network_service.cpp b/src/dbus/network/network_service.cpp index 50910978e..410a0c060 100644 --- a/src/dbus/network/network_service.cpp +++ b/src/dbus/network/network_service.cpp @@ -36,6 +36,7 @@ namespace { constexpr std::uint32_t k_nmDeviceTypeWifi = 2; // NMActiveConnectionState + constexpr std::uint32_t k_nmActiveConnectionStateActivating = 1; constexpr std::uint32_t k_nmActiveConnectionStateActivated = 2; template @@ -320,12 +321,13 @@ bool NetworkService::activateVpnConnection(const VpnConnectionInfo& vpn) { m_nm->callMethodAsync("ActivateConnection") .onInterface(k_nmInterface) .withArguments(sdbus::ObjectPath{vpnPath}, sdbus::ObjectPath{"/"}, sdbus::ObjectPath{"/"}) - .uponReplyInvoke([vpnName, vpnPath](std::optional err, sdbus::ObjectPath activePath) { + .uponReplyInvoke([this, vpnName, vpnPath](std::optional err, sdbus::ObjectPath activePath) { if (err.has_value()) { kLog.warn("ActivateConnection(vpn) failed name={} path={}: {}", vpnName, vpnPath, err->what()); } else { kLog.info("activating vpn name={} active={}", vpnName, std::string(activePath)); } + refresh(); }); return true; } catch (const sdbus::Error& e) { @@ -658,7 +660,7 @@ void NetworkService::refreshVpnConnections() { try { auto active = sdbus::createProxy(m_bus.connection(), k_nmBusName, activePath); const auto state = getPropertyOr(*active, k_nmActiveConnectionInterface, "State", 0U); - if (state != k_nmActiveConnectionStateActivated) { + if (state != k_nmActiveConnectionStateActivating && state != k_nmActiveConnectionStateActivated) { continue; } const auto profilePath = getPropertyOr(*active, k_nmActiveConnectionInterface,