a2d238d92e
Make Zed Agent closer to Cursor: deterministic DevOps path index, live Traefik port probe before blind edits, stop-after-edit, and quieter Russian progress.
48 lines
1.6 KiB
Python
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)
|