Skip to content
Permalink
Browse files

Support Tor socks proxy over IPv6

  • Loading branch information...
lontivero committed Nov 17, 2018
1 parent 6e62d47 commit 8127d0124e802969501cb45a8025133e5c67341d
@@ -7,6 +7,7 @@
using WalletWasabi.Gui.ViewModels.Validation;
using System.Net;
using System.Threading.Tasks;
using System.Net.Sockets;

namespace WalletWasabi.Gui.Tabs
{
@@ -117,6 +118,10 @@ public string ValidateTorHost()
}
if (IPAddress.TryParse(torHost, out var ip))
{
if(ip.AddressFamily == AddressFamily.InterNetworkV6 && !Socket.OSSupportsIPv6)
{
return "OS does not support IPv6 addresses.";
}
return string.Empty;
}

@@ -110,7 +110,7 @@ public void Start(bool ensureRunning, string dataDir)
Logger.LogInfo<TorProcessManager>($"Tor instance found at {torPath}.");
}

string torArguments = $"--SOCKSPort {TorSocks5EndPoint.Port}";
string torArguments = $"--SOCKSPort {TorSocks5EndPoint}";
if (!string.IsNullOrEmpty(LogFile))
{
IoHelpers.EnsureContainingDirectoryExists(LogFile);
@@ -60,7 +60,7 @@ public bool IsConnected
internal TorSocks5Client(IPEndPoint ipEndPoint)
{
TorSocks5EndPoint = ipEndPoint;
TcpClient = new TcpClient();
TcpClient = new TcpClient(ipEndPoint.AddressFamily);
AsyncLock = new AsyncLock();
}

@@ -235,7 +235,14 @@ internal async Task ConnectToDestinationAsync(string host, int port)
using (await AsyncLock.LockAsync())
{
TcpClient?.Dispose();
TcpClient = new TcpClient();
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;

0 comments on commit 8127d01

Please sign in to comment.
You can’t perform that action at this time.