Fix meek-client in Windows

This commit is contained in:
Micah Lee 2021-11-07 12:12:12 -08:00
parent 1eb2476d3c
commit 08ae2e616b
4 changed files with 31 additions and 9 deletions

View file

@ -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):