Support Tor socks proxy over IPv6
MODIFY
WalletWasabi.Gui/Tabs/SettingsViewModel.cs
WalletWasabi.Gui/Tabs/SettingsViewModel.cs
@@ -7,6 +7,7 @@ using Avalonia.Threading;
using WalletWasabi.Gui.ViewModels.Validation;
using System.Net;
using System.Threading.Tasks;
+using System.Net.Sockets;
namespace WalletWasabi.Gui.Tabs
{
@@ -117,6 +118,10 @@ namespace WalletWasabi.Gui.Tabs
}
if (IPAddress.TryParse(torHost, out var ip))
{
+ if(ip.AddressFamily == AddressFamily.InterNetworkV6 && !Socket.OSSupportsIPv6)
+ {
+ return "OS does not support IPv6 addresses.";
+ }
return string.Empty;
}

MODIFY
WalletWasabi/TorSocks5/TorProcessManager.cs
WalletWasabi/TorSocks5/TorProcessManager.cs
@@ -110,7 +110,7 @@ namespace WalletWasabi.TorSocks5
Logger.LogInfo<TorProcessManager>($"Tor instance found at {torPath}.");
}
- string torArguments = $"--SOCKSPort {TorSocks5EndPoint.Port}";
+ string torArguments = $"--SOCKSPort {TorSocks5EndPoint}";
if (!string.IsNullOrEmpty(LogFile))
{
IoHelpers.EnsureContainingDirectoryExists(LogFile);

MODIFY
WalletWasabi/TorSocks5/TorSocks5Client.cs
WalletWasabi/TorSocks5/TorSocks5Client.cs
@@ -60,7 +60,7 @@ namespace WalletWasabi.TorSocks5
internal TorSocks5Client(IPEndPoint ipEndPoint)
{
TorSocks5EndPoint = ipEndPoint;
- TcpClient = new TcpClient();
+ TcpClient = new TcpClient(ipEndPoint.AddressFamily);
AsyncLock = new AsyncLock();
}
@@ -235,7 +235,14 @@ namespace WalletWasabi.TorSocks5
using (await AsyncLock.LockAsync())
{
TcpClient?.Dispose();
+ if(IPAddress.TryParse(host, out IPAddress ip))
+ {
+ TcpClient = new TcpClient(ip.AddressFamily);
+ }
+ else
+ {
TcpClient = new TcpClient();
+ }
await TcpClient.ConnectAsync(host, port);
Stream = TcpClient.GetStream();
RemoteEndPoint = TcpClient.Client.RemoteEndPoint as IPEndPoint;

Support Tor socks proxy over IPv6