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

This commit is contained in:
Miguel Jacq 2021-10-25 11:45:50 +11:00
parent 93ea5eb068
commit a5ff00c1f5
2 changed files with 12 additions and 6 deletions

View file

@ -17,6 +17,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
""" """
import os
import subprocess import subprocess
import time import time
from queue import Queue, Empty from queue import Queue, Empty
@ -31,7 +32,7 @@ class Meek(object):
bridges, before connecting to Tor. bridges, before connecting to Tor.
""" """
def __init__(self, common): def __init__(self, common, get_tor_paths=None):
""" """
Set up the Meek object Set up the Meek object
""" """
@ -39,7 +40,9 @@ class Meek(object):
self.common = common self.common = common
self.common.log("Meek", "__init__") 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_path,
self.tor_geo_ip_file_path, self.tor_geo_ip_file_path,
@ -72,10 +75,12 @@ class Meek(object):
queue.put(line) queue.put(line)
out.close() out.close()
self.common.log("Meek", "start", self.meek_client_file_path)
# Abort early if we can't find the Meek client # Abort early if we can't find the Meek client
# common.get_tor_paths() has already checked it's a file if self.meek_client_file_path is None or not os.path.exists(
# so just abort if it's a NoneType object self.meek_client_file_path
if self.meek_client_file_path is None: ):
raise MeekNotFound() raise MeekNotFound()
# Start the Meek Client as a subprocess. # Start the Meek Client as a subprocess.
@ -186,6 +191,7 @@ class MeekNotRunning(Exception):
number it started on, in order to do domain fronting. number it started on, in order to do domain fronting.
""" """
class MeekNotFound(Exception): class MeekNotFound(Exception):
""" """
We were unable to find the Meek Client binary. We were unable to find the Meek Client binary.

View file

@ -49,7 +49,7 @@ class TorSettingsDialog(QtWidgets.QDialog):
self.common.log("TorSettingsDialog", "__init__") 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.setModal(True)
self.setWindowTitle(strings._("gui_tor_settings_window_title")) self.setWindowTitle(strings._("gui_tor_settings_window_title"))