From 54fe1c0f89bbaf274efe7368ec6c0266b6ee0f2e Mon Sep 17 00:00:00 2001 From: pcjones Date: Thu, 5 Sep 2024 14:24:42 +0200 Subject: [PATCH] Remove proxy support --- UmlautAdaptarr/Options/Proxy.cs | 27 ----------- UmlautAdaptarr/Options/ProxyOptions.cs | 32 ------------- UmlautAdaptarr/Program.cs | 2 - UmlautAdaptarr/Utilities/ProxyExtension.cs | 53 ---------------------- UmlautAdaptarr/appsettings.json | 14 ------ 5 files changed, 128 deletions(-) delete mode 100644 UmlautAdaptarr/Options/Proxy.cs delete mode 100644 UmlautAdaptarr/Options/ProxyOptions.cs delete mode 100644 UmlautAdaptarr/Utilities/ProxyExtension.cs diff --git a/UmlautAdaptarr/Options/Proxy.cs b/UmlautAdaptarr/Options/Proxy.cs deleted file mode 100644 index 63aaec3..0000000 --- a/UmlautAdaptarr/Options/Proxy.cs +++ /dev/null @@ -1,27 +0,0 @@ -namespace UmlautAdaptarr.Options; - -/// -/// Represents options for proxy configuration. -/// -public class Proxy -{ - /// - /// Gets or sets a value indicating whether to use a proxy. - /// - public bool Enabled { get; set; } - - /// - /// Gets or sets the address of the proxy. - /// - public string? Address { get; set; } - - /// - /// Gets or sets the username for proxy authentication. - /// - public string? Username { get; set; } - - /// - /// Gets or sets the password for proxy authentication. - /// - public string? Password { get; set; } -} \ No newline at end of file diff --git a/UmlautAdaptarr/Options/ProxyOptions.cs b/UmlautAdaptarr/Options/ProxyOptions.cs deleted file mode 100644 index 1bea2c6..0000000 --- a/UmlautAdaptarr/Options/ProxyOptions.cs +++ /dev/null @@ -1,32 +0,0 @@ -namespace UmlautAdaptarr.Options; - -/// -/// Represents options for proxy configuration. -/// -public class ProxyOptions -{ - /// - /// Gets or sets a value indicating whether to use a proxy. - /// - public bool Enabled { get; set; } - - /// - /// Gets or sets the address of the proxy. - /// - public string? Address { get; set; } - - /// - /// Gets or sets the username for proxy authentication. - /// - public string? Username { get; set; } - - /// - /// Gets or sets the password for proxy authentication. - /// - public string? Password { get; set; } - - /// - /// Bypass Local Ip Addresses , Proxy will ignore local Ip Addresses - /// - public bool BypassOnLocal { get; set; } -} \ No newline at end of file diff --git a/UmlautAdaptarr/Program.cs b/UmlautAdaptarr/Program.cs index 8123225..85149de 100644 --- a/UmlautAdaptarr/Program.cs +++ b/UmlautAdaptarr/Program.cs @@ -39,8 +39,6 @@ internal class Program DecompressionMethods.Brotli }; - var proxyOptions = configuration.GetSection("Proxy").Get(); - handler.ConfigureProxy(proxyOptions); return handler; }); diff --git a/UmlautAdaptarr/Utilities/ProxyExtension.cs b/UmlautAdaptarr/Utilities/ProxyExtension.cs deleted file mode 100644 index 6a448ba..0000000 --- a/UmlautAdaptarr/Utilities/ProxyExtension.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System; -using System.Net; -using UmlautAdaptarr.Options; - -namespace UmlautAdaptarr.Utilities -{ - /// - /// Extension methods for configuring proxies. - /// - public static class ProxyExtension - { - /// - /// Logger instance for logging proxy configurations. - /// - private static ILogger Logger = GlobalStaticLogger.Logger; - - /// - /// Configures the proxy settings for the provided HttpClientHandler instance. - /// - /// The HttpClientHandler instance to configure. - /// ProxyOptions options to be used for configuration. - /// The configured HttpClientHandler instance. - public static HttpClientHandler ConfigureProxy(this HttpClientHandler handler, ProxyOptions? proxyOptions) - { - try - { - if (proxyOptions != null && proxyOptions.Enabled) - { - Logger.LogInformation("Use Proxy {0}", proxyOptions.Address); - handler.UseProxy = true; - handler.Proxy = new WebProxy(proxyOptions.Address, proxyOptions.BypassOnLocal); - - if (!string.IsNullOrEmpty(proxyOptions.Username) && !string.IsNullOrEmpty(proxyOptions.Password)) - { - Logger.LogInformation("Use Proxy Credentials from User {0}", proxyOptions.Username); - handler.DefaultProxyCredentials = - new NetworkCredential(proxyOptions.Username, proxyOptions.Password); - } - } - else - { - Logger.LogDebug("No proxy was set"); - } - } - catch (Exception ex) - { - Logger.LogError(ex, "Error occurred while configuring proxy, no Proxy will be used!"); - } - - return handler; - } - } -} \ No newline at end of file diff --git a/UmlautAdaptarr/appsettings.json b/UmlautAdaptarr/appsettings.json index ed48d5e..b9b4ba0 100644 --- a/UmlautAdaptarr/appsettings.json +++ b/UmlautAdaptarr/appsettings.json @@ -64,19 +64,5 @@ "Enabled": false, "Host": "your_readarr_host_url", "ApiKey": "your_readarr_api_key" - }, - - // Docker Environment Variables: - // - Proxy__Enabled: true (set to false to disable) - // - Proxy__Address: http://yourproxyaddress:port - // - Proxy__Username: your_proxy_username - // - Proxy__Password: your_proxy_password - // - Proxy__BypassOnLocal: true (set to false to not bypass local IP addresses) - "Proxy": { - "Enabled": false, - "Address": "http://yourproxyaddress:port", - "Username": "your_proxy_username", - "Password": "your_proxy_password", - "BypassOnLocal": true } }