From 2fecc4e2710f50dd5410eba69afe31408cc6ffd7 Mon Sep 17 00:00:00 2001 From: Julius Caesar Date: Wed, 22 Jul 2026 14:07:34 -0700 Subject: [PATCH] fix: condition added to change connection status --- lib/modules/core/vpn.dart | 19 ++++++++++++++----- pubspec.yaml | 4 ++-- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/lib/modules/core/vpn.dart b/lib/modules/core/vpn.dart index 69aaf06..83900a2 100644 --- a/lib/modules/core/vpn.dart +++ b/lib/modules/core/vpn.dart @@ -120,6 +120,10 @@ class VPN { final ref = _container!; final loggerNotifier = ref.read(loggerStateProvider.notifier); final groupNotifier = ref.read(groupStateProvider.notifier); + final connectionState = ref.read(connectionStateProvider); + + final connectionStateIsError = + connectionState.status == ConnectionStatus.error; if (msg.startsWith("Data: Config index: ")) { final configIndex = msg.replaceAll("Data: Config index: ", ""); @@ -144,13 +148,13 @@ class VPN { _onFailerConnect(); } if (msg.startsWith("Data: VPN cancelled")) { - _closeTunnel(); + _closeTunnel(keepConnectionStatus: connectionStateIsError); } if (msg.startsWith("Data: VPN group failed")) { loggerNotifier.setSwitchingMethod(); } if (msg.startsWith("Data: VPN stopped")) { - _closeTunnel(); + _closeTunnel(keepConnectionStatus: connectionStateIsError); } if (msg.startsWith("Data: VPN connecting")) { _onLoading(); @@ -410,17 +414,22 @@ class VPN { analyticsService.logVpnDisconnected(); } - Future _closeTunnel() async { + Future _closeTunnel({bool keepConnectionStatus = false}) async { final connectionNotifier = _container?.read( connectionStateProvider.notifier, ); final vpnData = await _container?.read(vpnDataProvider.future); - connectionNotifier?.setDisconnecting(); + + if (!keepConnectionStatus) { + connectionNotifier?.setDisconnecting(); + } if (Platform.isIOS) { await _vpnBridge.disconnectVpn(); } await vpnData?.disableVPN(); - connectionNotifier?.setDisconnected(); + if (!keepConnectionStatus) { + connectionNotifier?.setDisconnected(); + } analyticsService.logVpnDisconnected(); _isReconnectMode = false; } diff --git a/pubspec.yaml b/pubspec.yaml index 761d151..0f9bfa7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: defyx_vpn description: "Defyx VPN - Secure, fast, and reliable VPN service providing global privacy protection with advanced encryption and multi-platform support" publish_to: "none" -version: 5.7.5+286 +version: 5.8.0+287 environment: sdk: ^3.8.0 @@ -105,7 +105,7 @@ msix_config: display_name: Defyx VPN publisher_display_name: UnboundTech UG identity_name: UnboundTechUG.6065AEC5A207 - msix_version: 5.7.4.285 + msix_version: 5.8.0.287 publisher: "CN=62937938-2AE2-4C12-9ED8-4C418C0CADF2" logo_path: assets/images/logo.png capabilities: runFullTrust,internetClientServer,privateNetworkClientServer,unvirtualizedResources