From 29d7927982da0cc26484410ead30758f242b3dfc Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 8 Feb 2026 12:14:07 -0600 Subject: add Timeout option for gluetun --- src/slskd/Core/Options.cs | 6 ++++++ src/slskd/Integrations/VPN/Clients/Gluetun.cs | 26 ++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index 565cbd4d..08fb1166 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -2360,6 +2360,12 @@ namespace slskd [NotNullOrWhiteSpace] public string Url { get; init; } + /// + /// Gets the timeout for HTTP requests to the Gluetun control server, in milliseconds. + /// + [Range(500, 10_000)] + public int Timeout { get; init; } = 1000; + /// /// Gets the Gluetun control server authentication method. /// diff --git a/src/slskd/Integrations/VPN/Clients/Gluetun.cs b/src/slskd/Integrations/VPN/Clients/Gluetun.cs index e9be123f..8c134599 100644 --- a/src/slskd/Integrations/VPN/Clients/Gluetun.cs +++ b/src/slskd/Integrations/VPN/Clients/Gluetun.cs @@ -1,4 +1,4 @@ -// +// // Copyright (c) slskd Team. All rights reserved. // // This program is free software: you can redistribute it and/or modify @@ -28,15 +28,37 @@ using System.Threading.Tasks; using Serilog; using static slskd.Options.IntegrationOptions.VpnOptions; +/// +/// Gluetun VPN client authentication methods. +/// public enum GluetunClientAuthenticationMethod { + /// + /// The Gluetun control server allows unauthenticated requests. + /// None, + + /// + /// The Glueton control server is configured to use HTTP Basic authentication; username and password are required. + /// Basic, + + /// + /// The Gluetun control server is configured to use API key authentication; apiKey is required. + /// ApiKey, } +/// +/// Gluetun VPN client. +/// public class Gluetun : IVPNClient { + /// + /// Initializes a new instance of the class. + /// + /// + /// public Gluetun(IHttpClientFactory httpClientFactory, IOptionsMonitor optionsMonitor) { HttpClientFactory = httpClientFactory; @@ -56,7 +78,7 @@ public class Gluetun : IVPNClient { using var http = HttpClientFactory.CreateClient(); - http.Timeout = TimeSpan.FromMilliseconds(1000); + http.Timeout = TimeSpan.FromMilliseconds(Options.Timeout); if (Options.Auth.Equals(GluetunClientAuthenticationMethod.Basic.ToString(), StringComparison.OrdinalIgnoreCase)) { -- cgit v1.2.3