fix: run VLESS Reality on Xray instead of sing-box for v2rayN

sing-box Hy2 stays on 8443+; port 443 VLESS uses Xray which pairs reliably with v2rayN/Xray-core clients.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-16 11:56:22 +08:00
parent 5685b869dc
commit c9895133cb
9 changed files with 305 additions and 39 deletions
+27 -5
View File
@@ -27,6 +27,7 @@ from stats import collect_node_stats
ROOT = Path(os.environ.get("JIEDIAN_ROOT", Path(__file__).resolve().parents[1]))
SECRET_FILE = ROOT / "data" / ".panel_secret"
RENDER_SCRIPT = ROOT / "scripts" / "render-server.py"
RENDER_XRAY_SCRIPT = ROOT / "scripts" / "render-xray.py"
_apply_lock = threading.Lock()
@@ -109,14 +110,28 @@ def render_singbox_config() -> tuple[bool, str]:
env=env,
)
if proc.returncode != 0:
return False, proc.stderr or proc.stdout or "配置生成失败"
return False, proc.stderr or proc.stdout or "sing-box 配置生成失败"
return True, "ok"
def restart_singbox_async() -> None:
"""后台重启 sing-box,避免添加/删除节点 API 长时间阻塞。"""
def render_xray_config() -> tuple[bool, str]:
env = os.environ.copy()
env["JIEDIAN_ROOT"] = str(ROOT)
proc = subprocess.run(
["python3", str(RENDER_XRAY_SCRIPT)],
capture_output=True,
text=True,
env=env,
)
if proc.returncode != 0:
return False, proc.stderr or proc.stdout or "Xray 配置生成失败"
return True, "ok"
def restart_services_async() -> None:
"""后台重启 sing-box 与 Xray。"""
subprocess.Popen(
["systemctl", "restart", "sing-box"],
["systemctl", "restart", "xray", "sing-box"],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)
@@ -126,10 +141,17 @@ def apply_singbox() -> tuple[bool, str]:
ok, msg = render_singbox_config()
if not ok:
return False, msg
restart_singbox_async()
ok, msg = render_xray_config()
if not ok:
return False, msg
restart_services_async()
return True, "ok"
def restart_singbox_async() -> None:
restart_services_async()
def apply_singbox_background(on_fail=None) -> None:
"""后台生成配置并重启 sing-box,避免阻塞 HTTP 请求导致 Nginx 503。"""