Remove internal socks http proxy and use .net60 socks support (#3240)

This commit is contained in:
Nicolas Dorier
2021-12-28 18:57:22 +09:00
committed by GitHub
parent 0e1b872777
commit 0dcfbe8581
5 changed files with 13 additions and 404 deletions

View File

@@ -1,14 +1,22 @@
using System.Net;
using System.Net.Http;
using BTCPayServer.Configuration;
using BTCPayServer.HostedServices;
namespace BTCPayServer.Services
{
public class Socks5HttpClientHandler : HttpClientHandler
{
public Socks5HttpClientHandler(Socks5HttpProxyServer sock5)
public Socks5HttpClientHandler(BTCPayServerOptions opts)
{
this.Proxy = new WebProxy(sock5.Uri);
if (opts.SocksEndpoint is IPEndPoint endpoint)
{
this.Proxy = new WebProxy($"socks5://{endpoint.Address}:{endpoint.Port}");
}
else if (opts.SocksEndpoint is DnsEndPoint endpoint2)
{
this.Proxy = new WebProxy($"socks5://{endpoint2.Host}:{endpoint2.Port}");
}
}
}
}