zapret-kvn/xray_fluent/application/protocol_core.py
loop-uh 3054036b4c
Some checks failed
Windows project source guards / test (push) Has been cancelled
NaiveProxy keys run on the stock naive client (core/naive.exe) as a loopback SOCKS helper behind sing-box
naive+https:// keys of the VPN bot are imported (paste, file, QR, subscription text), planned as a naive sidecar and
started by NaiveManager; the key line never reaches sing-box, logs or exports. Core pinned in the core lock
(klzgrad/naiveproxy v154.0.8037.49-5, SHA-256), resolved and verified like the other cores. Live run with a real canary
key passes on win10 (real planner, real sing-box.exe, stock naive.exe).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-27 06:00:21 -05:00

36 lines
1.4 KiB
Python

"""Fixed protocol ownership shared by planning, pools and runtime modules."""
from enum import Enum
class ProtocolCore(str, Enum):
SINGBOX = "sing-box"
XRAY = "xray"
HYSTERIA = "hysteria"
AMNEZIA = "amnezia"
NAIVE = "naive"
# Protocols whose complete native implementation is Xray-core (VLESS is handled first, by name).
XRAY_NATIVE_PROTOCOLS = frozenset({"vmess", "trojan"})
def protocol_core(node) -> ProtocolCore:
outbound = node.outbound or {}
protocol = str(outbound.get("protocol", outbound.get("type", node.scheme))).lower()
if protocol == "vless":
return ProtocolCore.XRAY
# VMess and Trojan are native Xray protocols (owner decision 2026-11-16): sing-box has no XHTTP
# transport for them and only approximates the rest. A node pasted as a raw sing-box outbound
# (`type` key, no Xray `protocol` key) is the user's own sing-box JSON and stays with sing-box.
if protocol in XRAY_NATIVE_PROTOCOLS and "protocol" in outbound:
return ProtocolCore.XRAY
# NaiveProxy keys (naive+https) run on the stock naive client, never on sing-box (owner decision 2026-11-27).
if protocol == "naive":
return ProtocolCore.NAIVE
if protocol in {"wireguard", "awg"}:
return ProtocolCore.AMNEZIA
# The official v2 client cannot consume Hysteria v1 configurations.
if protocol in {"hy2", "hysteria2"}:
return ProtocolCore.HYSTERIA
return ProtocolCore.SINGBOX