BIP79 Support

This commit is contained in:
Kukks
2020-01-06 13:57:32 +01:00
parent 1895e154d9
commit 89da4184ff
29 changed files with 1511 additions and 43 deletions

View File

@@ -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
});
}
}
}