mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 14:34:23 +01:00
BIP79 Support
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
using System;
|
||||
using NBitcoin;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NBitcoin;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BTCPayServer.Configuration;
|
||||
using com.LandonKey.SocksWebProxy;
|
||||
using com.LandonKey.SocksWebProxy.Proxy;
|
||||
using NBitcoin.Protocol.Connectors;
|
||||
using NBitcoin.Protocol;
|
||||
|
||||
@@ -16,9 +15,11 @@ namespace BTCPayServer.Services
|
||||
public class SocketFactory
|
||||
{
|
||||
private readonly BTCPayServerOptions _options;
|
||||
public readonly HttpClient SocksClient;
|
||||
public SocketFactory(BTCPayServerOptions options)
|
||||
{
|
||||
_options = options;
|
||||
SocksClient = CreateHttpClientUsingSocks();
|
||||
}
|
||||
public async Task<Socket> ConnectAsync(EndPoint endPoint, CancellationToken cancellationToken)
|
||||
{
|
||||
@@ -60,5 +61,21 @@ namespace BTCPayServer.Services
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private HttpClient CreateHttpClientUsingSocks()
|
||||
{
|
||||
if (_options.SocksEndpoint == null)
|
||||
return null;
|
||||
return new HttpClient(new HttpClientHandler
|
||||
{
|
||||
Proxy = new SocksWebProxy(new ProxyConfig()
|
||||
{
|
||||
Version = ProxyConfig.SocksVersion.Five,
|
||||
SocksAddress = _options.SocksEndpoint.AsOnionCatIPEndpoint().Address,
|
||||
SocksPort = _options.SocksEndpoint.AsOnionCatIPEndpoint().Port,
|
||||
}),
|
||||
UseProxy = true
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user