Files
EventHubAiRouter/scripts/vless-from-subscription-json.py
aleksey a2d238d92e
CI / build-gateway (push) Failing after 16s
CI / sync-config (push) Failing after 0s
feat(agent): hierarchical executor with path resolve, runtime probe, quiet UI
Make Zed Agent closer to Cursor: deterministic DevOps path index, live Traefik
port probe before blind edits, stop-after-edit, and quieter Russian progress.
2026-08-13 11:41:27 +03:00

48 lines
1.6 KiB
Python

#!/usr/bin/env python3
"""Extract first working vless:// URI from Happ/mireon subscription JSON."""
import json
import sys
import urllib.parse
path = sys.argv[1]
with open(path, "r", encoding="utf-8") as f:
data = json.load(f)
configs = data if isinstance(data, list) else [data]
for j in configs:
if not isinstance(j, dict):
continue
for ob in j.get("outbounds", []):
if ob.get("protocol") != "vless":
continue
tag = ob.get("tag") or "proxy"
st = ob.get("settings") or {}
vnext = (st.get("vnext") or [{}])[0]
addr, port = vnext.get("address"), vnext.get("port")
users = (vnext.get("users") or [{}])[0]
uid = users.get("id")
if not all([addr, port, uid]) or addr in ("0.0.0.0", "127.0.0.1"):
continue
flow = users.get("flow") or ""
stream = ob.get("streamSettings") or {}
net = stream.get("network") or "tcp"
sec = stream.get("security") or "none"
rs = stream.get("realitySettings") or {}
ts = stream.get("tlsSettings") or {}
sni = rs.get("serverName") or ts.get("serverName") or ""
params = {"encryption": "none", "security": sec, "type": net}
if sni:
params["sni"] = sni
if rs.get("publicKey"):
params["pbk"] = rs["publicKey"]
if rs.get("shortId"):
params["sid"] = rs["shortId"]
if rs.get("fingerprint"):
params["fp"] = rs["fingerprint"]
if flow:
params["flow"] = flow
q = urllib.parse.urlencode(params)
print(f"vless://{uid}@{addr}:{port}?{q}#{tag}")
sys.exit(0)
sys.exit(1)