Skip to content

Commit

Permalink
Add global flag to disable tor
Browse files Browse the repository at this point in the history
  • Loading branch information
wieslawsoltes committed Nov 21, 2023
1 parent 0afd32b commit 7f35992
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
12 changes: 5 additions & 7 deletions WalletWasabi.Daemon/Global.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ public Global(string dataDir, string configFilePath, Config config)
DataDir = dataDir;
ConfigFilePath = configFilePath;
Config = config;
TorSettings = IsTorEnabled() ? null : new TorSettings(DataDir, distributionFolderPath: EnvironmentHelpers.GetFullBaseDirectory(), Config.TerminateTorOnExit, Environment.ProcessId);
TorSettings = IsTorEnabled
? new TorSettings(DataDir, distributionFolderPath: EnvironmentHelpers.GetFullBaseDirectory(), Config.TerminateTorOnExit, Environment.ProcessId)
: null;
HostedServices = new HostedServices();

var networkWorkFolderPath = Path.Combine(DataDir, "BitcoinStore", Network.ToString());
Expand Down Expand Up @@ -121,6 +123,8 @@ public Global(string dataDir, string configFilePath, Config config)
/// <summary>Cancellation token to cancel <see cref="InitializeNoWalletAsync(TerminateService)"/> processing.</summary>
private CancellationTokenSource StoppingCts { get; } = new();

public static bool IsTorEnabled = true;

public string DataDir { get; }
public TorSettings? TorSettings { get; }
public BitcoinStore BitcoinStore { get; }
Expand Down Expand Up @@ -156,12 +160,6 @@ public Global(string dataDir, string configFilePath, Config config)
private AllTransactionStore AllTransactionStore { get; }
private IndexStore IndexStore { get; }

private bool IsTorEnabled()
{
return !OperatingSystem.IsAndroid()
&& !OperatingSystem.IsIOS();
}

private WasabiHttpClientFactory BuildHttpClientFactory(Func<Uri> backendUriGetter) =>
new(
Config.UseTor ? TorSettings?.SocksEndpoint : null,
Expand Down
2 changes: 2 additions & 0 deletions WalletWasabi.Fluent.Android/MainActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public class MainActivity : AvaloniaMainActivity<App>

private void Program_Main()
{
Global.IsTorEnabled = false;

_app = WasabiAppBuilder
.Create("Wasabi GUI", System.Array.Empty<string>())
// TODO:
Expand Down
2 changes: 2 additions & 0 deletions WalletWasabi.Fluent.iOS/AppDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public class AppDelegate : AvaloniaAppDelegate<App>

private void Program_Main()
{
Global.IsTorEnabled = false;

_app = WasabiAppBuilder
.Create("Wasabi GUI", System.Array.Empty<string>())
// TODO:
Expand Down
6 changes: 5 additions & 1 deletion WalletWasabi.Fluent/Services.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,12 @@ public static class Services
/// </summary>
public static void Initialize(Global global, UiConfig uiConfig, SingleInstanceChecker singleInstanceChecker, TerminateService terminateService)
{
if (Global.IsTorEnabled)
{
Guard.NotNull(nameof(global.TorSettings), global.TorSettings);
}

Guard.NotNull(nameof(global.DataDir), global.DataDir);
// Guard.NotNull(nameof(global.TorSettings), global.TorSettings);
Guard.NotNull(nameof(global.BitcoinStore), global.BitcoinStore);
Guard.NotNull(nameof(global.HttpClientFactory), global.HttpClientFactory);
Guard.NotNull(nameof(global.LegalChecker), global.LegalChecker);
Expand Down

0 comments on commit 7f35992

Please sign in to comment.