Fix the paths
MODIFY
WalletWasabi/Microservices/MicroserviceHelpers.cs
WalletWasabi/Microservices/MicroserviceHelpers.cs
@@ -7,7 +7,7 @@ namespace WalletWasabi.Microservices
{
public static class MicroserviceHelpers
{
- public static string GetBinaryPath(string binaryNameWithoutExtension)
+ public static string GetBinaryFolder()
{
var fullBaseDirectory = EnvironmentHelpers.GetFullBaseDirectory();
@@ -15,15 +15,15 @@ namespace WalletWasabi.Microservices
string path;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
- path = Path.Combine(commonPartialPath, $"win64", $"{binaryNameWithoutExtension}.exe");
+ path = Path.Combine(commonPartialPath, $"win64");
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
- path = Path.Combine(commonPartialPath, $"lin64", binaryNameWithoutExtension);
+ path = Path.Combine(commonPartialPath, $"lin64");
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
- path = Path.Combine(commonPartialPath, $"osx64", binaryNameWithoutExtension);
+ path = Path.Combine(commonPartialPath, $"osx64");
}
else
{
@@ -32,5 +32,10 @@ namespace WalletWasabi.Microservices
return path;
}
+
+ public static string GetBinaryPath(string binaryNameWithoutExtension)
+ {
+ return Path.Combine(GetBinaryFolder(), RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? $"{binaryNameWithoutExtension}.exe" : $"{binaryNameWithoutExtension}");
+ }
}
}

MODIFY
WalletWasabi/Tor/TorInstallator.cs
WalletWasabi/Tor/TorInstallator.cs
@@ -34,18 +34,7 @@ namespace WalletWasabi.Tor
// Common for all platforms.
await ExtractZipFileAsync(Path.Combine(Settings.DistributionFolder, "data-folder.zip"), Settings.TorDir).ConfigureAwait(false);
- // File differs per platform.
- await ExtractZipFileAsync(Path.Combine(Settings.DistributionFolder, $"tor-{GetPlatformIdentifier()}.zip"), Settings.TorDir).ConfigureAwait(false);
-
- if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
- {
- // Set sufficient file permission.
- string shellCommand = $"chmod -R 750 {Settings.TorDir}";
- await EnvironmentHelpers.ShellExecAsync(shellCommand, waitForExit: true).ConfigureAwait(false);
- Logger.LogInfo($"Shell command executed: '{shellCommand}'.");
- }
-
- bool verification = File.Exists(Settings.TorBinaryFilePath);
+ bool verification = File.Exists(Settings.TorDataDir);
Logger.LogDebug($"Tor installation finished. Installed correctly? {verification}.");
return verification;
@@ -59,34 +48,21 @@ namespace WalletWasabi.Tor
}
/// <summary>
- /// Verifies that Tor is installed and checksums of installed binaries are correct.
+ /// Verifies that Tor datadir is exists.
/// </summary>
- /// <returns>Returns <c>true</c> if <see cref="TorSettings.TorBinaryFilePath"/> is present, <c>false</c> otherwise.</returns>
+ /// <returns>Returns <c>true</c> if <see cref="TorSettings.TorDataDir"/> is present, <c>false</c> otherwise.</returns>
public async Task<bool> VerifyInstallationAsync()
{
try
{
- if (!File.Exists(Settings.TorBinaryFilePath))
+ if (!Directory.Exists(Settings.TorDataDir))
{
- Logger.LogInfo($"Tor instance NOT found at '{Settings.TorBinaryFilePath}'. Attempting to acquire it.");
- return await InstallAsync().ConfigureAwait(false);
- }
- else if (!IoHelpers.CheckExpectedHash(Settings.HashSourcePath, Settings.DistributionFolder))
- {
- Logger.LogInfo("Install the latest Tor version.");
- string backupDir = $"{Settings.TorDir}_backup";
-
- if (Directory.Exists(backupDir))
- {
- Directory.Delete(backupDir, recursive: true);
- }
-
- Directory.Move(Settings.TorDir, backupDir);
+ Logger.LogInfo($"Tor datadir NOT found at '{Settings.TorDataDir}'. Attempting to extract it.");
return await InstallAsync().ConfigureAwait(false);
}
else
{
- Logger.LogInfo($"Tor instance found at '{Settings.TorBinaryFilePath}'.");
+ Logger.LogInfo($"Tor datadir found at '{Settings.TorDataDir}'.");
return true;
}
}

MODIFY
WalletWasabi/Tor/TorSettings.cs
WalletWasabi/Tor/TorSettings.cs
@@ -2,6 +2,7 @@ using System;
using System.IO;
using System.Net;
using System.Runtime.InteropServices;
+using WalletWasabi.Microservices;
namespace WalletWasabi.Tor
{
@@ -19,27 +20,15 @@ namespace WalletWasabi.Tor
public TorSettings(string dataDir, string logFilePath, string distributionFolderPath)
{
TorDir = Path.Combine(dataDir, "tor");
- TorBinaryDir = Path.Combine(TorDir, "Tor");
+ TorBinaryFilePath = MicroserviceHelpers.GetBinaryPath(Path.Combine("Tor", "tor"));
+ TorBinaryDir = Path.Combine(MicroserviceHelpers.GetBinaryFolder(), "Tor");
+
TorDataDir = Path.Combine(dataDir, "tordata");
LogFilePath = logFilePath;
DistributionFolder = distributionFolderPath;
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
- {
- TorBinaryFilePath = $@"{TorBinaryDir}\tor.exe";
- HashSourcePath = $@"{TorBinaryDir}\tor.exe";
- GeoIpPath = $@"{TorDir}\Data\Tor\geoip";
- GeoIp6Path = $@"{TorDir}\Data\Tor\geoip6";
- }
- else
- {
- TorBinaryFilePath = $@"{TorBinaryDir}/tor";
- HashSourcePath = RuntimeInformation.IsOSPlatform(OSPlatform.OSX)
- ? $@"{TorBinaryDir}/tor.real"
- : $@"{TorBinaryDir}/tor";
- GeoIpPath = $@"{TorDir}/Data/Tor/geoip";
- GeoIp6Path = $@"{TorDir}/Data/Tor/geoip6";
- }
+ GeoIpPath = Path.Combine(TorDir, "Data", "Tor", "geoip");
+ GeoIp6Path = Path.Combine(TorDir, "Data", "Tor", "geoip6");
}
/// <summary>Full directory path where Tor is installed (or supposed to be installed).</summary>
@@ -58,9 +47,6 @@ namespace WalletWasabi.Tor
/// <summary>Full Tor distribution folder where Tor installation files are located.</summary>
public string DistributionFolder { get; }
- /// <summary>Full path to Tor binary that is checked against a check sum.</summary>
- public string HashSourcePath { get; }
-
/// <summary>Full path to executable file that is used to start Tor process.</summary>
public string TorBinaryFilePath { get; }

Fix the paths