aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Core/ConnectionWatchdog.cs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/slskd/Core/ConnectionWatchdog.cs b/src/slskd/Core/ConnectionWatchdog.cs
index b7a4fa34..0cf30484 100644
--- a/src/slskd/Core/ConnectionWatchdog.cs
+++ b/src/slskd/Core/ConnectionWatchdog.cs
@@ -23,6 +23,7 @@ namespace slskd
using System.Threading;
using System.Threading.Tasks;
using Serilog;
+ using slskd.Integrations.VPN;
using Soulseek;
/// <summary>
@@ -41,15 +42,21 @@ namespace slskd
/// Initializes a new instance of the <see cref="ConnectionWatchdog"/> class.
/// </summary>
/// <param name="soulseekClient"></param>
+ /// <param name="vpnService"></param>
/// <param name="optionsMonitor"></param>
+ /// <param name="optionsAtStartup"></param>
/// <param name="applicationState"></param>
public ConnectionWatchdog(
ISoulseekClient soulseekClient,
+ VPNService vpnService,
IOptionsMonitor<Options> optionsMonitor,
+ OptionsAtStartup optionsAtStartup,
IManagedState<State> applicationState)
{
Client = soulseekClient;
+ VPN = vpnService;
OptionsMonitor = optionsMonitor;
+ OptionsAtStartup = optionsAtStartup;
ApplicationState = applicationState;
WatchdogTimer = new System.Timers.Timer()
@@ -77,9 +84,11 @@ namespace slskd
public bool IsAttemptingConnection => SyncRoot.CurrentCount == 0;
private ISoulseekClient Client { get; }
+ private VPNService VPN { get; }
private bool Disposed { get; set; }
private ILogger Log { get; } = Serilog.Log.ForContext<Application>();
private IOptionsMonitor<Options> OptionsMonitor { get; set; }
+ private OptionsAtStartup OptionsAtStartup { get; set; }
private IManagedState<State> ApplicationState { get; }
private SemaphoreSlim SyncRoot { get; } = new SemaphoreSlim(1, 1);
private object StateLock { get; } = new object();
@@ -232,6 +241,12 @@ namespace slskd
return;
}
+ if (OptionsAtStartup.Integration.Vpn.Required && !VPN.IsReady)
+ {
+ Log.Debug("AttemptConnection aborted; VPN is not yet ready (status: {Status})", VPN.Status);
+ return;
+ }
+
CancellationTokenSource = new CancellationTokenSource();
if (attempts > 0)