diff options
| author | JP Dillingham <jp@dillingham.me> | 2026-02-08 11:34:14 -0600 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2026-02-08 11:34:14 -0600 |
| commit | 09b42a04b36e324c0c1f1f20bd1c66e95217f19f (patch) | |
| tree | 3b980eea6fb8aaf63c1e9d7b6f6025bd55db741c | |
| parent | 2a9c370eed0b94f7773d2d4eca4887155b0835a6 (diff) | |
| download | slskd-09b42a04b36e324c0c1f1f20bd1c66e95217f19f.tar.gz | |
docs
| -rw-r--r-- | config/slskd.example.yml | 4 | ||||
| -rw-r--r-- | src/slskd/Integrations/VPN/Clients/Gluetun.cs (renamed from src/slskd/Integrations/VPN/GluetunClient.cs) | 6 | ||||
| -rw-r--r-- | src/slskd/Integrations/VPN/VPNService.cs | 37 |
3 files changed, 39 insertions, 8 deletions
diff --git a/config/slskd.example.yml b/config/slskd.example.yml index 4f8cd157..9be02b85 100644 --- a/config/slskd.example.yml +++ b/config/slskd.example.yml @@ -238,10 +238,10 @@ # polling_interval: 2500 # gluetun: # url: http://localhost:8000 -# auth: apikey +# auth: apikey # or basic or none # api_key: <gluetun API key> # username: <username if using basic auth> -# password: <password if using basic auth># +# password: <password if using basic auth> # webhooks: # my_webhook: # on: diff --git a/src/slskd/Integrations/VPN/GluetunClient.cs b/src/slskd/Integrations/VPN/Clients/Gluetun.cs index 2d1588dd..e9be123f 100644 --- a/src/slskd/Integrations/VPN/GluetunClient.cs +++ b/src/slskd/Integrations/VPN/Clients/Gluetun.cs @@ -35,15 +35,15 @@ public enum GluetunClientAuthenticationMethod ApiKey, } -public class GluetunClient : IVPNClient +public class Gluetun : IVPNClient { - public GluetunClient(IHttpClientFactory httpClientFactory, IOptionsMonitor<Options> optionsMonitor) + public Gluetun(IHttpClientFactory httpClientFactory, IOptionsMonitor<Options> optionsMonitor) { HttpClientFactory = httpClientFactory; OptionsMonitor = optionsMonitor; } - private ILogger Log { get; } = Serilog.Log.ForContext<GluetunClient>(); + private ILogger Log { get; } = Serilog.Log.ForContext<Gluetun>(); private IHttpClientFactory HttpClientFactory { get; } private IOptionsMonitor<Options> OptionsMonitor { get; } private GluetunVpnOptions Options => OptionsMonitor.CurrentValue.Integration.Vpn.Gluetun; diff --git a/src/slskd/Integrations/VPN/VPNService.cs b/src/slskd/Integrations/VPN/VPNService.cs index dbe7d2c1..18003341 100644 --- a/src/slskd/Integrations/VPN/VPNService.cs +++ b/src/slskd/Integrations/VPN/VPNService.cs @@ -26,8 +26,19 @@ using System.Threading.Tasks; using Serilog; using Soulseek; +/// <summary> +/// VPN integration. +/// </summary> public class VPNService : IDisposable { + /// <summary> + /// Initializes a new instance of the <see cref="VPNService"/> class. + /// </summary> + /// <param name="optionsAtStartup"></param> + /// <param name="optionsMonitor"></param> + /// <param name="stateMutator"></param> + /// <param name="soulseekClient"></param> + /// <param name="httpClientFactory"></param> public VPNService( OptionsAtStartup optionsAtStartup, IOptionsMonitor<Options> optionsMonitor, @@ -54,9 +65,9 @@ public class VPNService : IDisposable // we can revisit this if/when we add other options besides gluetun if (!string.IsNullOrEmpty(OptionsMonitor.CurrentValue.Integration.Vpn.Gluetun.Url)) { - Client = new GluetunClient(HttpClientFactory, OptionsMonitor); + Client = new Gluetun(HttpClientFactory, OptionsMonitor); - Log.Information("VPN integration enabled using {Client}", typeof(GluetunClient).Name); + Log.Information("VPN integration enabled using {Client}", typeof(Gluetun).Name); return; } @@ -64,7 +75,15 @@ public class VPNService : IDisposable } } + /// <summary> + /// Gets a value indicating whether the configured VPN client is ready (connected, and if port forwarding + /// is configured, a port has been provided). + /// </summary> public bool IsReady { get; private set; } = false; + + /// <summary> + /// Gets the most recent VPN client status. + /// </summary> public VPNStatus Status { get; private set; } = new VPNStatus(); private ISoulseekClient SoulseekClient { get; } @@ -78,6 +97,9 @@ public class VPNService : IDisposable private bool Disposed { get; set; } private SemaphoreSlim TimerElapsedLock { get; } = new SemaphoreSlim(1, 1); + /// <summary> + /// Starts polling the configured VPN client for status updates. + /// </summary> public void StartPolling() { if (Timer is not null && !Timer.Enabled) @@ -87,6 +109,9 @@ public class VPNService : IDisposable } } + /// <summary> + /// Stops polling the configured VPN client for status updates. + /// </summary> public void StopPolling() { if (Timer is not null && Timer.Enabled) @@ -96,12 +121,19 @@ public class VPNService : IDisposable } } + /// <summary> + /// Disposes this instance. + /// </summary> public void Dispose() { Dispose(disposing: true); GC.SuppressFinalize(this); } + /// <summary> + /// Disposes this instance. + /// </summary> + /// <param name="disposing"></param> protected virtual void Dispose(bool disposing) { if (!Disposed) @@ -148,7 +180,6 @@ public class VPNService : IDisposable * update VPNService state * apply a configuration overlay to set the forwarded port (if there is one) * update application state (via StateMutator) - * if IsReady changed during this invocation, disposition the ReadyTaskCompletionSource */ if (status is null || !status.IsConnected) { |
