From b96dad3864cb13d791c1f1c46e7ebcb8f6ddaf66 Mon Sep 17 00:00:00 2001 From: Michael Suchacz <203725896+ibetitsmike@users.noreply.github.com> Date: Tue, 23 Sep 2025 11:25:02 +0200 Subject: [PATCH] fix: add vpn lifecycle check on Connect on Launch feature --- App/App.xaml.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/App/App.xaml.cs b/App/App.xaml.cs index a07af43..3eeeef8 100644 --- a/App/App.xaml.cs +++ b/App/App.xaml.cs @@ -228,13 +228,21 @@ private async Task InitializeServicesAsync(CancellationToken cancellationToken = var attemptCoderConnection = settingsTask.Result?.ConnectOnLaunch ?? false; if (dependenciesLoaded && attemptCoderConnection) { - try + var rpcModel = rpcController.GetState(); + if (rpcModel.VpnLifecycle == VpnLifecycle.Stopped) { - await rpcController.StartVpn(cancellationToken); + try + { + await rpcController.StartVpn(cancellationToken); + } + catch (Exception ex) + { + _logger.LogError(ex, "Failed to connect on launch"); + } } - catch (Exception ex) + else { - _logger.LogError(ex, "Failed to connect on launch"); + _logger.LogInformation($"Not connecting on launch, VPN lifecycle is {rpcModel.VpnLifecycle}"); } }