aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2026-02-15 11:20:34 -0600
committerJP Dillingham <jp@dillingham.me>2026-02-15 11:20:34 -0600
commitd7faef9b6817a5f55d691f11793a29d31aaa182e (patch)
tree8e5e3800368e84c41a3b53ae6f02901386e26b01 /src
parenta6aa646a29b13b2e571a6150da0218e2740c62d8 (diff)
parent8ab17908255a71469ce38332e2ad2b2952309ff4 (diff)
downloadslskd-d7faef9b6817a5f55d691f11793a29d31aaa182e.tar.gz
Merge remote-tracking branch 'origin/master' into search-args
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Integrations/VPN/VPNService.cs23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/slskd/Integrations/VPN/VPNService.cs b/src/slskd/Integrations/VPN/VPNService.cs
index bc3eb668..db09c041 100644
--- a/src/slskd/Integrations/VPN/VPNService.cs
+++ b/src/slskd/Integrations/VPN/VPNService.cs
@@ -140,7 +140,7 @@ public class VPNService : IDisposable
{
if (disposing)
{
- Timer.Dispose();
+ Timer?.Dispose();
}
Disposed = true;
@@ -149,12 +149,20 @@ public class VPNService : IDisposable
private async Task CheckConnection()
{
+ if (Client is null)
+ {
+ throw new VPNClientException("VPN client not properly initialized; something went seriously wrong! Please report to GitHub.");
+ }
+
var options = OptionsMonitor.CurrentValue.Integration.Vpn;
bool isReadyNow = false;
VPNStatus status = new VPNStatus();
// one at a time!
- await TimerElapsedLock.WaitAsync(0);
+ if (!await TimerElapsedLock.WaitAsync(0))
+ {
+ return;
+ }
try
{
@@ -162,8 +170,12 @@ public class VPNService : IDisposable
try
{
- status = await Client.GetStatusAsync()
- ?? throw new VPNClientException("VPN client returned an invalid response");
+ status = await Client.GetStatusAsync();
+
+ if (status is null)
+ {
+ throw new VPNClientException("VPN client returned an invalid response");
+ }
}
catch (Exception ex)
{
@@ -201,6 +213,9 @@ public class VPNService : IDisposable
}
}
+ // if the VPN client returned null, swap it for a default instance to prevent null refs
+ status ??= new VPNStatus();
+
if (!IsReady && isReadyNow)
{
if (options.PortForwarding)