diff --git a/BTCPayServer/BTCPayServer.csproj b/BTCPayServer/BTCPayServer.csproj index 1dc1a659b..47a0c18c3 100644 --- a/BTCPayServer/BTCPayServer.csproj +++ b/BTCPayServer/BTCPayServer.csproj @@ -35,7 +35,6 @@ - diff --git a/BTCPayServer/Controllers/WalletsController.PSBT.cs b/BTCPayServer/Controllers/WalletsController.PSBT.cs index 8e774bd35..3ef04b66c 100644 --- a/BTCPayServer/Controllers/WalletsController.PSBT.cs +++ b/BTCPayServer/Controllers/WalletsController.PSBT.cs @@ -164,15 +164,7 @@ namespace BTCPayServer.Controllers if (TempData.TryGetValue( "bpu", out var bpu) && !string.IsNullOrEmpty(bpu?.ToString()) && Uri.TryCreate(bpu.ToString(), UriKind.Absolute, out var endpoint)) { TempData.Remove("bpu"); - var httpClient = _socks5HttpClientFactory.CreateClient("payjoin"); - if (endpoint.IsOnion() && httpClient == null) - { - return null; - } - else - { - httpClient = _httpClientFactory.CreateClient("payjoin"); - } + var httpClient = _httpClientFactory.CreateClient("payjoin"); var cloned = psbt.Clone(); diff --git a/BTCPayServer/Controllers/WalletsController.cs b/BTCPayServer/Controllers/WalletsController.cs index 87951d4a0..f98588e4b 100644 --- a/BTCPayServer/Controllers/WalletsController.cs +++ b/BTCPayServer/Controllers/WalletsController.cs @@ -50,7 +50,6 @@ namespace BTCPayServer.Controllers private readonly WalletReceiveStateService _WalletReceiveStateService; private readonly EventAggregator _EventAggregator; private readonly SettingsRepository _settingsRepository; - private readonly Socks5HttpClientFactory _socks5HttpClientFactory; private readonly IHttpClientFactory _httpClientFactory; public RateFetcher RateFetcher { get; } @@ -70,7 +69,6 @@ namespace BTCPayServer.Controllers WalletReceiveStateService walletReceiveStateService, EventAggregator eventAggregator, SettingsRepository settingsRepository, - Socks5HttpClientFactory socks5HttpClientFactory, IHttpClientFactory httpClientFactory) { _currencyTable = currencyTable; @@ -88,7 +86,6 @@ namespace BTCPayServer.Controllers _WalletReceiveStateService = walletReceiveStateService; _EventAggregator = eventAggregator; _settingsRepository = settingsRepository; - _socks5HttpClientFactory = socks5HttpClientFactory; _httpClientFactory = httpClientFactory; } diff --git a/BTCPayServer/Hosting/BTCPayServerServices.cs b/BTCPayServer/Hosting/BTCPayServerServices.cs index 340375149..8c5875980 100644 --- a/BTCPayServer/Hosting/BTCPayServerServices.cs +++ b/BTCPayServer/Hosting/BTCPayServerServices.cs @@ -68,7 +68,6 @@ namespace BTCPayServer.Hosting services.TryAddSingleton(); services.TryAddSingleton(); services.TryAddSingleton(); - services.TryAddSingleton(); services.TryAddSingleton(); services.TryAddSingleton(); services.TryAddSingleton(o => diff --git a/BTCPayServer/Services/SocketFactory.cs b/BTCPayServer/Services/SocketFactory.cs index a8aa32f9b..e508b452c 100644 --- a/BTCPayServer/Services/SocketFactory.cs +++ b/BTCPayServer/Services/SocketFactory.cs @@ -1,57 +1,13 @@ -using System.Collections.Concurrent; -using System.Net; -using System.Net.Http; +using System.Net; using System.Net.Sockets; using System.Threading; using System.Threading.Tasks; using BTCPayServer.Configuration; -using MihaZupan; using NBitcoin.Protocol.Connectors; using NBitcoin.Protocol; namespace BTCPayServer.Services { - public class Socks5HttpClientFactory : IHttpClientFactory - { - private readonly BTCPayServerOptions _options; - - public Socks5HttpClientFactory(BTCPayServerOptions options) - { - _options = options; - } - - private static (string Host, int Port)? ToParts(EndPoint endpoint) - { - switch (endpoint) - { - case DnsEndPoint dns: - return (dns.Host, dns.Port); - case IPEndPoint ipEndPoint: - return (ipEndPoint.Address.ToString(), ipEndPoint.Port); - } - - return null; - } - - private ConcurrentDictionary cachedClients = new ConcurrentDictionary(); - public HttpClient CreateClient(string name) - { - return cachedClients.GetOrAdd(name, s => - { - var parts = ToParts(_options.SocksEndpoint); - if (!parts.HasValue) - { - return null; - } - - var proxy = new HttpToSocks5Proxy(parts.Value.Host, parts.Value.Port); - return new HttpClient( - new HttpClientHandler {Proxy = proxy, }, - true); - }); - } - } - public class SocketFactory { private readonly BTCPayServerOptions _options;