aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMicah Lee <micah@micahflee.com>2021-11-07 12:12:12 -0800
committerMicah Lee <micah@micahflee.com>2021-11-07 12:12:12 -0800
commit9430439b5f02829e3677ac187e1db7a52076ddad (patch)
tree36208e4077b23bccc379272ed2c2ef93a04b6ec1
parent472e383b7d0f4040e4963ffff95da1e86fe85cca (diff)
downloadonionshare-9430439b5f02829e3677ac187e1db7a52076ddad.tar.gz
onionshare-9430439b5f02829e3677ac187e1db7a52076ddad.zip
Fix meek-client in Windows
-rw-r--r--cli/onionshare_cli/meek.py12
-rw-r--r--desktop/README.md2
-rwxr-xr-xdesktop/scripts/build-meek-client.py16
-rw-r--r--desktop/src/onionshare/moat_dialog.py10
4 files changed, 31 insertions, 9 deletions
diff --git a/cli/onionshare_cli/meek.py b/cli/onionshare_cli/meek.py
index b2e70dc1..c5df7b7f 100644
--- a/cli/onionshare_cli/meek.py
+++ b/cli/onionshare_cli/meek.py
@@ -85,6 +85,10 @@ class Meek(object):
self.common.log("Meek", "start", "Starting meek client")
if self.common.platform == "Windows":
+ env = os.environ.copy()
+ for key in self.meek_env:
+ env[key] = self.meek_env[key]
+
# In Windows, hide console window when opening meek-client.exe subprocess
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
@@ -100,7 +104,7 @@ class Meek(object):
stderr=subprocess.PIPE,
startupinfo=startupinfo,
bufsize=1,
- env=self.meek_env,
+ env=env,
text=True,
)
else:
@@ -129,6 +133,7 @@ class Meek(object):
# read stdout without blocking
try:
line = q.get_nowait()
+ self.common.log("Meek", "start", line.strip())
except Empty:
# no stdout yet?
pass
@@ -143,6 +148,10 @@ class Meek(object):
)
break
+ if "CMETHOD-ERROR" in line:
+ self.cleanup()
+ raise MeekNotRunning()
+
if self.meek_port:
self.meek_proxies = {
"http": f"socks5h://{self.meek_host}:{self.meek_port}",
@@ -150,6 +159,7 @@ class Meek(object):
}
else:
self.common.log("Meek", "start", "Could not obtain the meek port")
+ self.cleanup()
raise MeekNotRunning()
def cleanup(self):
diff --git a/desktop/README.md b/desktop/README.md
index 408b6852..7f13ad70 100644
--- a/desktop/README.md
+++ b/desktop/README.md
@@ -65,7 +65,7 @@ python scripts\get-tor-windows.py
### Compile dependencies
-Install Go. The simplest way to make sure everything works is to install Go by following [these instructions](https://golang.org/doc/install).
+Install Go. The simplest way to make sure everything works is to install Go by following [these instructions](https://golang.org/doc/install). (In Windows, make sure to install the 32-bit version of Go, such as `go1.17.3.windows-386.msi`.)
Download and compile `meek-client`:
diff --git a/desktop/scripts/build-meek-client.py b/desktop/scripts/build-meek-client.py
index d043754c..af58173a 100755
--- a/desktop/scripts/build-meek-client.py
+++ b/desktop/scripts/build-meek-client.py
@@ -28,6 +28,7 @@ import shutil
import os
import subprocess
import inspect
+import platform
def main():
@@ -46,16 +47,21 @@ def main():
root_path = os.path.dirname(
os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
)
- dist_path = os.path.join(root_path, "src", "onionshare", "resources", "tor")
+ if platform.system() == "Windows":
+ dist_path = os.path.join(root_path, "src", "onionshare", "resources", "tor", "Tor")
+ bin_filename = "meek-client.exe"
+ else:
+ dist_path = os.path.join(root_path, "src", "onionshare", "resources", "tor")
+ bin_filename = "meek-client"
- bin_path = os.path.expanduser("~/go/bin/meek-client")
+ bin_path = os.path.join(os.path.expanduser("~"), "go", "bin", bin_filename)
shutil.copyfile(
os.path.join(bin_path),
- os.path.join(dist_path, "meek-client"),
+ os.path.join(dist_path, bin_filename),
)
- os.chmod(os.path.join(dist_path, "meek-client"), 0o755)
+ os.chmod(os.path.join(dist_path, bin_filename), 0o755)
- print(f"Installed meek-client in {dist_path}")
+ print(f"Installed {bin_filename} in {dist_path}")
if __name__ == "__main__":
diff --git a/desktop/src/onionshare/moat_dialog.py b/desktop/src/onionshare/moat_dialog.py
index 85b5e888..84a52390 100644
--- a/desktop/src/onionshare/moat_dialog.py
+++ b/desktop/src/onionshare/moat_dialog.py
@@ -26,7 +26,7 @@ import json
from . import strings
from .gui_common import GuiCommon
-from onionshare_cli.meek import MeekNotFound
+from onionshare_cli.meek import MeekNotFound, MeekNotRunning
class MoatDialog(QtWidgets.QDialog):
@@ -237,7 +237,13 @@ class MoatThread(QtCore.QThread):
try:
self.meek.start()
except MeekNotFound:
- self.common.log("MoatThread", "run", f"Could not find the Meek Client")
+ self.common.log("MoatThread", "run", f"Could not find meek-client")
+ self.bridgedb_error.emit()
+ return
+ except MeekNotRunning:
+ self.common.log(
+ "MoatThread", "run", f"Ran meek-client, but there was an error"
+ )
self.bridgedb_error.emit()
return