[backend/core] Add support for HTTP proxy authentication
This commit is contained in:
parent
ea7bcfa652
commit
09919bdc77
3 changed files with 15 additions and 2 deletions
|
@ -71,6 +71,8 @@ public sealed class Config
|
|||
public sealed class NetworkSection
|
||||
{
|
||||
public string? HttpProxy { get; init; } = null;
|
||||
public string? HttpProxyUser { get; init; } = null!;
|
||||
public string? HttpProxyPass { get; init; } = null!;
|
||||
}
|
||||
|
||||
public sealed class DatabaseSection
|
||||
|
|
|
@ -37,7 +37,16 @@ public class CustomHttpClient : HttpClient, IService<HttpClient>, 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<FastFallback>(), security, proxy != null);
|
||||
var innerHandler = new SocketsHttpHandler
|
||||
{
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Add table
Reference in a new issue