From aad63c933e1a8bbef028e99c1e31d14998e00343 Mon Sep 17 00:00:00 2001 From: Daniel Cazzulino Date: Wed, 19 May 2021 17:59:16 -0300 Subject: [PATCH] Fix torrc path lookup under Linux Fixes #3. --- src/dotnet-tor/ConfigCommand.cs | 7 +++++-- src/dotnet-tor/TorCommand.cs | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/dotnet-tor/ConfigCommand.cs b/src/dotnet-tor/ConfigCommand.cs index 1b6f06c..a8a9c21 100644 --- a/src/dotnet-tor/ConfigCommand.cs +++ b/src/dotnet-tor/ConfigCommand.cs @@ -37,10 +37,13 @@ async Task RunAsync() (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "notepad.exe" : "nano"); + var zipName = Path.GetFileNameWithoutExtension(zipPath); + if (zipName.EndsWith(".tar")) + zipName = Path.GetFileNameWithoutExtension(zipName); + var configPath = Path.Combine( settings.ExtractedToolsDirectory, - Path.GetFileNameWithoutExtension(zipPath), - "Data", "Tor", "torrc"); + zipName, "Data", "Tor", "torrc"); var torProxy = new TorSharpProxy(settings); await torProxy.ConfigureAsync(); diff --git a/src/dotnet-tor/TorCommand.cs b/src/dotnet-tor/TorCommand.cs index 425434e..2d28cbb 100644 --- a/src/dotnet-tor/TorCommand.cs +++ b/src/dotnet-tor/TorCommand.cs @@ -63,10 +63,13 @@ async Task RunAsync(int proxy, int socks, int control, CancellationToken cancell await tor.ConfigureAsync(); cancellation.ThrowIfCancellationRequested(); + var zipName = Path.GetFileNameWithoutExtension(zipPath); + if (zipName.EndsWith(".tar")) + zipName = Path.GetFileNameWithoutExtension(zipName); + var configPath = Path.Combine( settings.ExtractedToolsDirectory, - Path.GetFileNameWithoutExtension(zipPath), - "Data", "Tor", "torrc"); + zipName, "Data", "Tor", "torrc"); if (!File.Exists(configPath)) throw new ArgumentException($"Tor configuration file not found at expected location {configPath}");