diff --git a/Iceshrimp.Backend/Core/Configuration/Config.cs b/Iceshrimp.Backend/Core/Configuration/Config.cs index 76e70971..ece0e692 100644 --- a/Iceshrimp.Backend/Core/Configuration/Config.cs +++ b/Iceshrimp.Backend/Core/Configuration/Config.cs @@ -70,7 +70,9 @@ public sealed class Config public sealed class NetworkSection { - public string? HttpProxy { get; init; } = null; + public string? HttpProxy { get; init; } = null; + public string? HttpProxyUser { get; init; } = null!; + public string? HttpProxyPass { get; init; } = null!; } public sealed class DatabaseSection diff --git a/Iceshrimp.Backend/Core/Services/CustomHttpClient.cs b/Iceshrimp.Backend/Core/Services/CustomHttpClient.cs index 77d9175f..ac9c83b6 100644 --- a/Iceshrimp.Backend/Core/Services/CustomHttpClient.cs +++ b/Iceshrimp.Backend/Core/Services/CustomHttpClient.cs @@ -37,7 +37,16 @@ public class CustomHttpClient : HttpClient, IService, ISingletonServ ILoggerFactory loggerFactory ) { - var proxy = network.Value.HttpProxy != null ? new WebProxy(network.Value.HttpProxy) : null; + // Configure HTTP proxy, if enabled + WebProxy? proxy = null; + if (network.Value.HttpProxy != null) + { + var creds = network.Value.HttpProxyUser != null || network.Value.HttpProxyPass != null + ? new NetworkCredential(network.Value.HttpProxyUser, network.Value.HttpProxyPass) + : null; + proxy = new WebProxy(network.Value.HttpProxy, false, null, creds); + } + var fastFallback = new FastFallback(loggerFactory.CreateLogger(), security, proxy != null); var innerHandler = new SocketsHttpHandler { diff --git a/Iceshrimp.Backend/configuration.ini b/Iceshrimp.Backend/configuration.ini index 04ac8a87..8f9588ca 100644 --- a/Iceshrimp.Backend/configuration.ini +++ b/Iceshrimp.Backend/configuration.ini @@ -80,6 +80,8 @@ PublicPreview = Public [Network] ;; Uncomment to use the specified HTTP proxy for all outgoing requests. Backend restart is required to apply changes. ;HttpProxy = 127.0.0.1:8080 +;HttpProxyUser = +;HttpProxyPass = [Performance] ;; Maximum number of incoming federation requests to handle concurrently.