mirror of
https://github.com/onionshare/onionshare.git
synced 2025-01-10 03:37:28 -03:00
Fix meek-client in Windows
This commit is contained in:
parent
472e383b7d
commit
9430439b5f
4 changed files with 31 additions and 9 deletions
|
@ -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):
|
||||
|
|
|
@ -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`:
|
||||
|
||||
|
|
|
@ -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__":
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue