fix: URL-encode share link params for v2rayNG SNI parsing
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+12
-2
@@ -21,6 +21,13 @@ def load_env() -> dict[str, str]:
|
||||
return env
|
||||
|
||||
|
||||
def _qs(value: str) -> str:
|
||||
"""URL-encode query / userinfo values for share links."""
|
||||
# quote() leaves unreserved chars like '.' unencoded; some clients (v2rayNG)
|
||||
# misparsed sni=www.microsoft.com — force dots encoded for compatibility.
|
||||
return quote(value, safe="").replace(".", "%2E")
|
||||
|
||||
|
||||
def build_links(node: dict, env: dict | None = None) -> dict[str, str]:
|
||||
env = env or load_env()
|
||||
vps_ip = env["VPS_IP"]
|
||||
@@ -34,8 +41,11 @@ def build_links(node: dict, env: dict | None = None) -> dict[str, str]:
|
||||
vless = (
|
||||
f"vless://{node['uuid']}@{vps_ip}:443"
|
||||
f"?encryption=none&flow=xtls-rprx-vision&security=reality"
|
||||
f"&sni={reality_sni}&fp=chrome&pbk={public_key}&sid={short_id}"
|
||||
f"&sni={_qs(reality_sni)}&fp=chrome&pbk={_qs(public_key)}&sid={_qs(short_id)}"
|
||||
f"&spx=%2F&type=tcp#{name}"
|
||||
)
|
||||
hy2 = f"hy2://{node['hy2_password']}@{domain}:{port}?sni={domain}#{name}-Hy2"
|
||||
hy2 = (
|
||||
f"hy2://{_qs(node['hy2_password'])}@{domain}:{port}"
|
||||
f"?sni={_qs(domain)}#{name}-Hy2"
|
||||
)
|
||||
return {"vless": vless, "hy2": hy2}
|
||||
|
||||
Reference in New Issue
Block a user