| import os |
| import subprocess |
| import urllib.request |
| import zipfile |
|
|
| |
| xray_url = "https://github.com/XTLS/Xray-core/releases/latest/download/Xray-linux-64.zip" |
| zip_path = "xray.zip" |
| bin_dir = "./xray_bin" |
|
|
| if not os.path.exists(bin_dir): |
| os.makedirs(bin_dir) |
|
|
| print("Downloading Xray...") |
| urllib.request.urlretrieve(xray_url, zip_path) |
|
|
| print("Extracting Xray...") |
| with zipfile.ZipFile(zip_path, 'r') as zip_ref: |
| zip_ref.extractall(bin_dir) |
|
|
| |
| os.chmod(f"{bin_dir}/xray", 0o755) |
|
|
| |
| if os.path.exists(zip_path): |
| os.remove(zip_path) |
|
|
| |
| print("Starting fake Gradio interface...") |
| with open("dummy.py", "w") as f: |
| f.write("import gradio as gr\nwith gr.Blocks() as demo:\n gr.Markdown('# Config Running')\ndemo.launch(server_name='0.0.0.0', server_port=7861, prevent_thread_lock=True)") |
|
|
| |
| subprocess.Popen(["python", "dummy.py"]) |
|
|
| |
| print("Starting Xray Core...") |
| subprocess.run([f"{bin_dir}/xray", "-config", "config.json"]) |