From 24b734299857c2a231918bcad02a3b06dbf3baf4 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 15 Feb 2026 10:43:19 -0600 Subject: add a null coalesce of Timer when disposing --- src/slskd/Integrations/VPN/VPNService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/slskd/Integrations/VPN/VPNService.cs b/src/slskd/Integrations/VPN/VPNService.cs index bc3eb668..ead0ce60 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; -- cgit v1.2.3 From bd9fb7485d4ef3383a0d2504f14ad3eebd6bae3e Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 15 Feb 2026 10:43:35 -0600 Subject: ensure Client is not null before attempting to check --- src/slskd/Integrations/VPN/VPNService.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/slskd/Integrations/VPN/VPNService.cs b/src/slskd/Integrations/VPN/VPNService.cs index ead0ce60..d82a8bfe 100644 --- a/src/slskd/Integrations/VPN/VPNService.cs +++ b/src/slskd/Integrations/VPN/VPNService.cs @@ -149,6 +149,11 @@ 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(); -- cgit v1.2.3 From 79a17ea8d4cbe6b96e39818cb57053bce6fa08d7 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 15 Feb 2026 10:43:54 -0600 Subject: properly check result of WaitAsync --- src/slskd/Integrations/VPN/VPNService.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/slskd/Integrations/VPN/VPNService.cs b/src/slskd/Integrations/VPN/VPNService.cs index d82a8bfe..95d897a3 100644 --- a/src/slskd/Integrations/VPN/VPNService.cs +++ b/src/slskd/Integrations/VPN/VPNService.cs @@ -159,7 +159,10 @@ public class VPNService : IDisposable VPNStatus status = new VPNStatus(); // one at a time! - await TimerElapsedLock.WaitAsync(0); + if (!await TimerElapsedLock.WaitAsync(0)) + { + return; + } try { -- cgit v1.2.3 From e3c5ecd5ff1ff3cb5f6a66ebb726e6d5058cd4cd Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 15 Feb 2026 10:44:15 -0600 Subject: make behavior of a null response from client more obvious --- src/slskd/Integrations/VPN/VPNService.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/slskd/Integrations/VPN/VPNService.cs b/src/slskd/Integrations/VPN/VPNService.cs index 95d897a3..1f59db99 100644 --- a/src/slskd/Integrations/VPN/VPNService.cs +++ b/src/slskd/Integrations/VPN/VPNService.cs @@ -170,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) { -- cgit v1.2.3 From e510c8a9bdd728a1c8c9429d6a88ac522a2d85b6 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 15 Feb 2026 10:44:33 -0600 Subject: swap null with a default instance to prevent null refs --- src/slskd/Integrations/VPN/VPNService.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/slskd/Integrations/VPN/VPNService.cs b/src/slskd/Integrations/VPN/VPNService.cs index 1f59db99..db09c041 100644 --- a/src/slskd/Integrations/VPN/VPNService.cs +++ b/src/slskd/Integrations/VPN/VPNService.cs @@ -213,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) -- cgit v1.2.3