From 6e97421cd7d56d04efe37f7793ec77dd5b8b1d5a Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 1 Feb 2026 14:11:00 -0600 Subject: add VPN options --- src/slskd/Core/Options.cs | 88 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) (limited to 'src') diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index 200b0ee8..545dedac 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -33,6 +33,7 @@ namespace slskd using slskd.Authentication; using slskd.Configuration; using slskd.Events; + using slskd.Integrations.VPN; using slskd.Relay; using slskd.Shares; using slskd.Validation; @@ -2274,6 +2275,12 @@ namespace slskd /// public class IntegrationOptions { + /// + /// Gets VPN options. + /// + [Validate] + public VpnOptions Vpn { get; init; } = new(); + /// /// Gets webhook configuration. /// @@ -2298,6 +2305,87 @@ namespace slskd [Validate] public PushbulletOptions Pushbullet { get; init; } = new PushbulletOptions(); + /// + /// VPN options. + /// + public class VpnOptions + { + /// + /// Gets a value indicating whether the VPN integration is enabled. + /// + public bool Enabled { get; init; } = false; + + /// + /// Gets Gluetun options. + /// + public GluetunVpnOptions Gluetun { get; init; } = new GluetunVpnOptions(); + + /// + /// Gluetun options. + /// + public class GluetunVpnOptions : IValidatableObject + { + /// + /// Gets the Gluetun integration version. + /// + /// + /// Only v1 of the Gluetun API exists right now; this is to ease a transition if there's ever a v2. + /// + [Range(1, 1)] + public int Version { get; init; } = 1; + + /// + /// Gets the fully qualified root URL for the Gluetun control server. + /// + [NotNullOrWhiteSpace] + public string Url { get; init; } + + /// + /// Gets the Gluetun control server authentication method. + /// + [Enum(typeof(GluetunClientAuthOptions), ignoreCase: true)] + public string Auth { get; init; } + + /// + /// Gets the username used for basic auth. + /// + public string Username { get; init; } + + /// + /// Gets the password used for basic auth. + /// + public string Password { get; init; } + + /// + /// Gets the API key used for API key auth. + /// + public string ApiKey { get; init; } + + public IEnumerable Validate(ValidationContext validationContext) + { + var results = new List(); + + if (string.Equals(Auth, GluetunClientAuthOptions.Basic.ToString(), StringComparison.OrdinalIgnoreCase)) + { + if (string.IsNullOrWhiteSpace(Username) || string.IsNullOrWhiteSpace(Password)) + { + results.Add(new ValidationResult("Username and Password are required when using Basic auth")); + } + } + + if (string.Equals(Auth, GluetunClientAuthOptions.ApiKey.ToString(), StringComparison.OrdinalIgnoreCase)) + { + if (string.IsNullOrWhiteSpace(ApiKey)) + { + results.Add(new ValidationResult("ApiKey is required when using ApiKey auth")); + } + } + + return results; + } + } + } + /// /// Webhook configuration. /// -- cgit v1.2.3