2020-06-29 04:44:35 +02:00
|
|
|
using System.Net;
|
2020-04-09 10:38:55 +02:00
|
|
|
using System.Net.Http;
|
2021-12-28 10:57:22 +01:00
|
|
|
using BTCPayServer.Configuration;
|
2020-04-09 10:38:55 +02:00
|
|
|
using BTCPayServer.HostedServices;
|
|
|
|
|
|
|
|
namespace BTCPayServer.Services
|
|
|
|
{
|
|
|
|
public class Socks5HttpClientHandler : HttpClientHandler
|
|
|
|
{
|
2021-12-28 10:57:22 +01:00
|
|
|
public Socks5HttpClientHandler(BTCPayServerOptions opts)
|
2020-04-09 10:38:55 +02:00
|
|
|
{
|
2021-12-28 10:57:22 +01:00
|
|
|
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}");
|
|
|
|
}
|
2020-04-09 10:38:55 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|