Skip to content

Commit fd99c1d

Browse files
authored
fix: add vpn lifecycle check on Connect on Launch feature (#157)
Fixes: #155
1 parent 71ef69b commit fd99c1d

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

App/App.xaml.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,13 +228,21 @@ private async Task InitializeServicesAsync(CancellationToken cancellationToken =
228228
var attemptCoderConnection = settingsTask.Result?.ConnectOnLaunch ?? false;
229229
if (dependenciesLoaded && attemptCoderConnection)
230230
{
231-
try
231+
var rpcModel = rpcController.GetState();
232+
if (rpcModel.VpnLifecycle == VpnLifecycle.Stopped)
232233
{
233-
await rpcController.StartVpn(cancellationToken);
234+
try
235+
{
236+
await rpcController.StartVpn(cancellationToken);
237+
}
238+
catch (Exception ex)
239+
{
240+
_logger.LogError(ex, "Failed to connect on launch");
241+
}
234242
}
235-
catch (Exception ex)
243+
else
236244
{
237-
_logger.LogError(ex, "Failed to connect on launch");
245+
_logger.LogInformation($"Not connecting on launch, VPN lifecycle is {rpcModel.VpnLifecycle}");
238246
}
239247
}
240248

0 commit comments

Comments
 (0)