diff options
| author | JP Dillingham <jp@dillingham.me> | 2026-02-08 12:14:07 -0600 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2026-02-08 12:14:07 -0600 |
| commit | 29d7927982da0cc26484410ead30758f242b3dfc (patch) | |
| tree | 91cd1003aed69784b6ce93fbecdb6dcbfc134e1a /src | |
| parent | 357a49a8012ad9b8377103a51d4e939138f3ce01 (diff) | |
| download | slskd-29d7927982da0cc26484410ead30758f242b3dfc.tar.gz | |
add Timeout option for gluetun
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Core/Options.cs | 6 | ||||
| -rw-r--r-- | src/slskd/Integrations/VPN/Clients/Gluetun.cs | 26 |
2 files changed, 30 insertions, 2 deletions
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 @@ -2361,6 +2361,12 @@ namespace slskd public string Url { get; init; } /// <summary> + /// Gets the timeout for HTTP requests to the Gluetun control server, in milliseconds. + /// </summary> + [Range(500, 10_000)] + public int Timeout { get; init; } = 1000; + + /// <summary> /// Gets the Gluetun control server authentication method. /// </summary> [Enum(typeof(GluetunClientAuthenticationMethod), ignoreCase: true)] 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 file="GluetunClient.cs" company="slskd Team"> +// <copyright file="Gluetun.cs" company="slskd Team"> // 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; +/// <summary> +/// Gluetun VPN client authentication methods. +/// </summary> public enum GluetunClientAuthenticationMethod { + /// <summary> + /// The Gluetun control server allows unauthenticated requests. + /// </summary> None, + + /// <summary> + /// The Glueton control server is configured to use HTTP Basic authentication; username and password are required. + /// </summary> Basic, + + /// <summary> + /// The Gluetun control server is configured to use API key authentication; apiKey is required. + /// </summary> ApiKey, } +/// <summary> +/// Gluetun VPN client. +/// </summary> public class Gluetun : IVPNClient { + /// <summary> + /// Initializes a new instance of the <see cref="Gluetun"/> class. + /// </summary> + /// <param name="httpClientFactory"></param> + /// <param name="optionsMonitor"></param> public Gluetun(IHttpClientFactory httpClientFactory, IOptionsMonitor<Options> 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)) { |
