try to reuse cloudflared file

This commit is contained in:
Concedo 2024-01-05 18:04:09 +08:00
parent d37c94bcd9
commit 20261049c9

View file

@ -2143,12 +2143,18 @@ def setuptunnel():
tunnelproc.wait()
if os.name == 'nt':
print("Downloading Cloudflare Tunnel for Windows...")
subprocess.run("curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-windows-amd64.exe -o cloudflared.exe", shell=True, capture_output=True, text=True, check=True, encoding='utf-8')
if os.path.exists("cloudflared.exe"):
print("Cloudflared file exists, reusing it...")
else:
print("Downloading Cloudflare Tunnel for Windows...")
subprocess.run("curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-windows-amd64.exe -o cloudflared.exe", shell=True, capture_output=True, text=True, check=True, encoding='utf-8')
else:
print("Downloading Cloudflare Tunnel for Linux...")
subprocess.run("curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 -o cloudflared-linux-amd64", shell=True, capture_output=True, text=True, check=True, encoding='utf-8')
subprocess.run("chmod +x 'cloudflared-linux-amd64'", shell=True)
if os.path.exists("cloudflared-linux-amd64"):
print("Cloudflared file exists, reusing it...")
else:
print("Downloading Cloudflare Tunnel for Linux...")
subprocess.run("curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 -o cloudflared-linux-amd64", shell=True, capture_output=True, text=True, check=True, encoding='utf-8')
subprocess.run("chmod +x 'cloudflared-linux-amd64'", shell=True)
tunnel_thread = threading.Thread(target=run_tunnel)
tunnel_thread.start()
except Exception as ex: