From 8543d215dcdc92fb621a55299a04d8fcef738223 Mon Sep 17 00:00:00 2001 From: Miguel Jacq Date: Mon, 25 Oct 2021 11:45:50 +1100 Subject: [PATCH] Fix-ups for detecting if the meek binary doesn't exist. Pass the GUI's get_tor_paths down to the CLI when instantiating Meek object --- cli/onionshare_cli/meek.py | 16 +++++++++++----- desktop/src/onionshare/tor_settings_dialog.py | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/cli/onionshare_cli/meek.py b/cli/onionshare_cli/meek.py index ff44cb13..762a454c 100644 --- a/cli/onionshare_cli/meek.py +++ b/cli/onionshare_cli/meek.py @@ -17,6 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . """ +import os import subprocess import time from queue import Queue, Empty @@ -31,7 +32,7 @@ class Meek(object): bridges, before connecting to Tor. """ - def __init__(self, common): + def __init__(self, common, get_tor_paths=None): """ Set up the Meek object """ @@ -39,7 +40,9 @@ class Meek(object): self.common = common self.common.log("Meek", "__init__") - get_tor_paths = self.common.get_tor_paths + # Set the path of the meek binary + if not get_tor_paths: + get_tor_paths = self.common.get_tor_paths ( self.tor_path, self.tor_geo_ip_file_path, @@ -72,10 +75,12 @@ class Meek(object): queue.put(line) out.close() + self.common.log("Meek", "start", self.meek_client_file_path) + # Abort early if we can't find the Meek client - # common.get_tor_paths() has already checked it's a file - # so just abort if it's a NoneType object - if self.meek_client_file_path is None: + if self.meek_client_file_path is None or not os.path.exists( + self.meek_client_file_path + ): raise MeekNotFound() # Start the Meek Client as a subprocess. @@ -186,6 +191,7 @@ class MeekNotRunning(Exception): number it started on, in order to do domain fronting. """ + class MeekNotFound(Exception): """ We were unable to find the Meek Client binary. diff --git a/desktop/src/onionshare/tor_settings_dialog.py b/desktop/src/onionshare/tor_settings_dialog.py index 13edd112..6737ae4b 100644 --- a/desktop/src/onionshare/tor_settings_dialog.py +++ b/desktop/src/onionshare/tor_settings_dialog.py @@ -49,7 +49,7 @@ class TorSettingsDialog(QtWidgets.QDialog): self.common.log("TorSettingsDialog", "__init__") - self.meek = Meek(common) + self.meek = Meek(common, get_tor_paths=self.common.gui.get_tor_paths) self.setModal(True) self.setWindowTitle(strings._("gui_tor_settings_window_title"))