TorSocks5Client: Remove AssertConnectedAsync.
MODIFY
WalletWasabi/Tor/Socks5/TorSocks5Client.cs
WalletWasabi/Tor/Socks5/TorSocks5Client.cs
@@ -10,7 +10,6 @@ using System.Threading.Tasks;
using WalletWasabi.Crypto.Randomness;
using WalletWasabi.Helpers;
using WalletWasabi.Logging;
-using WalletWasabi.Tor.Http;
using WalletWasabi.Tor.Socks5.Exceptions;
using WalletWasabi.Tor.Socks5.Models.Bases;
using WalletWasabi.Tor.Socks5.Models.Fields.ByteArrayFields;
@@ -194,16 +193,6 @@ namespace WalletWasabi.Tor.Socks5
return Stream;
}
- private async Task ConnectToDestinationAsync(EndPoint destination, CancellationToken cancellationToken = default)
- {
- if (!destination.TryGetHostAndPort(out string? host, out int? port))
- {
- throw new ArgumentException("Endpoint type is not supported.", nameof(destination));
- }
-
- await ConnectToDestinationAsync(host, port.Value, cancellationToken).ConfigureAwait(false);
- }
-
/// <summary>
/// Sends <see cref="CmdField.Connect"/> command to SOCKS5 server to instruct it to connect to
/// <paramref name="host"/>:<paramref name="port"/> on behalf of this client.
@@ -265,26 +254,6 @@ namespace WalletWasabi.Tor.Socks5
}
}
- private async Task AssertConnectedAsync(CancellationToken token = default)
- {
- if (!IsConnected)
- {
- // try reconnect, maybe the server came online already
- try
- {
- await ConnectToDestinationAsync(RemoteEndPoint, token).ConfigureAwait(false);
- }
- catch (Exception ex) when (IsConnectionRefused(ex))
- {
- throw new TorConnectionException($"{nameof(TorSocks5Client)} is not connected to '{RemoteEndPoint}'.", ex);
- }
- if (!IsConnected)
- {
- throw new TorConnectionException($"{nameof(TorSocks5Client)} is not connected to '{RemoteEndPoint}'.");
- }
- }
- }
-
#endregion Initializers
#region Methods
@@ -338,8 +307,6 @@ namespace WalletWasabi.Tor.Socks5
{
try
{
- await AssertConnectedAsync(cancellationToken).ConfigureAwait(false);
-
using (await AsyncLock.LockAsync(cancellationToken).ConfigureAwait(false))
{
var stream = TcpClient.GetStream();

TorSocks5Client: Remove AssertConnectedAsync.

Signed-off-by: Kiminuo <kiminuo@protonmail.com>