WasabiSynchronizer: Continue even if a Tor exception is encountered
MODIFY
WalletWasabi/Services/WasabiSynchronizer.cs
WalletWasabi/Services/WasabiSynchronizer.cs
@@ -13,6 +13,7 @@ using WalletWasabi.Logging;
using WalletWasabi.Models;
using WalletWasabi.Stores;
using WalletWasabi.Tor.Socks5.Exceptions;
+using WalletWasabi.Tor.Socks5.Models.Fields.OctetFields;
using WalletWasabi.WebClients.Wasabi;
namespace WalletWasabi.Services;
@@ -178,7 +179,6 @@ public class WasabiSynchronizer : NotifyPropertyChangedBase, IThirdPartyFeeProvi
{
TorStatus = innerEx is TorConnectionException ? TorStatus.NotRunning : TorStatus.Running;
BackendStatus = BackendStatus.NotConnected;
- HandleIfGenSocksServFail(ex);
HandleIfGenSocksServFail(innerEx);
throw;
}
@@ -292,7 +292,7 @@ public class WasabiSynchronizer : NotifyPropertyChangedBase, IThirdPartyFeeProvi
finally
{
Interlocked.CompareExchange(ref _running, StateStopped, StateStopping); // If IsStopping, make it stopped.
- Logger.LogTrace("< Wasabi synchronizer thread ends.");
+ Logger.LogDebug("Synchronizer is fully stopped now.");
}
});
@@ -305,15 +305,19 @@ public class WasabiSynchronizer : NotifyPropertyChangedBase, IThirdPartyFeeProvi
private void HandleIfGenSocksServFail(Exception ex)
{
- // IS GenSocksServFail?
- if (ex.ToString().Contains("GeneralSocksServerFailure", StringComparison.OrdinalIgnoreCase))
+ bool isFail = false;
+
+ if (ex is TorConnectCommandFailedException torEx)
+ {
+ isFail = torEx.RepField == RepField.GeneralSocksServerFailure || torEx.RepField == RepField.OnionServiceIntroFailed;
+ }
+
+ if (isFail)
{
- // IS GenSocksServFail
DoGenSocksServFail();
}
else
{
- // NOT GenSocksServFail
DoNotGenSocksServFail();
}
}

MODIFY
WalletWasabi/Tor/Socks5/Exceptions/TorConnectCommandFailedException.cs
WalletWasabi/Tor/Socks5/Exceptions/TorConnectCommandFailedException.cs
@@ -6,7 +6,7 @@ namespace WalletWasabi.Tor.Socks5.Exceptions;
/// <summary>
/// Thrown when Tor SOCKS5 responds with an error code to previously sent <see cref="CmdField.Connect"/> command.
/// </summary>
-public class TorConnectCommandFailedException : TorException
+public class TorConnectCommandFailedException : TorConnectionException
{
public TorConnectCommandFailedException(RepField rep) : base($"Tor SOCKS5 proxy responded with {rep}.")
{

MODIFY
WalletWasabi/Tor/Socks5/Models/ReplyType.cs
WalletWasabi/Tor/Socks5/Models/ReplyType.cs
-using Microsoft.VisualBasic;
-
namespace WalletWasabi.Tor.Socks5.Models;
/// <seealso href="https://github.com/torproject/torspec/blob/main/proposals/304-socks5-extending-hs-error-codes.txt"/>
@@ -12,7 +10,16 @@ public enum ReplyType : byte
NetworkUnreachable = 0x03,
HostUnreachable = 0x04,
ConnectionRefused = 0x05,
+
+ /// <summary>An operation failed because we waited too long for an [Tor] exit to do something.</summary>
+ /// <remarks>
+ /// This error can happen if the host you're trying to connect to isn't
+ /// responding to traffic. It can also happen if an exit is overloaded, and
+ /// unable to answer your replies in a timely manner.
+ /// <para>In either case, trying later, or on a different circuit, might help.</para>
+ /// </remarks>
TtlExpired = 0x06,
+
CommandNotSupported = 0x07,
AddressTypeNotSupported = 0x08,

WasabiSynchronizer: Continue even if a Tor exception is encountered