handle clean_env for remotetunnel

This commit is contained in:
Concedo 2025-07-17 18:21:22 +08:00
parent a417cd87c7
commit afca31bfbe

View file

@ -6084,8 +6084,17 @@ def setuptunnel(global_memory, has_sd):
else: else:
print("Starting Cloudflare Tunnel for Linux, please wait...", flush=True) print("Starting Cloudflare Tunnel for Linux, please wait...", flush=True)
tunnelbinary = "./cloudflared-linux-amd64" tunnelbinary = "./cloudflared-linux-amd64"
tunnelproc = None
if sys.platform == "linux":
clean_env = os.environ.copy()
clean_env.pop("LD_LIBRARY_PATH", None)
clean_env["PATH"] = "/usr/bin:/bin"
tunnelproc = subprocess.Popen(f"{tunnelbinary} tunnel --url {httpsaffix}://localhost:{int(args.port)}{ssladd}", text=True, encoding='utf-8', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, env=clean_env)
else:
tunnelproc = subprocess.Popen(f"{tunnelbinary} tunnel --url {httpsaffix}://localhost:{int(args.port)}{ssladd}", text=True, encoding='utf-8', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE) tunnelproc = subprocess.Popen(f"{tunnelbinary} tunnel --url {httpsaffix}://localhost:{int(args.port)}{ssladd}", text=True, encoding='utf-8', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE)
time.sleep(10) time.sleep(10)
def tunnel_reader(): def tunnel_reader():
nonlocal tunnelproc,tunneloutput,tunnelrawlog nonlocal tunnelproc,tunneloutput,tunnelrawlog
pattern = r'https://[\w\.-]+\.trycloudflare\.com' pattern = r'https://[\w\.-]+\.trycloudflare\.com'