fork: security=tls (self-signed + pinnedPeerCertSha256) becomes the default hop transport
reverse-over-REALITY is broken on xray >= 26.7 (Rvs control channel never registers; XTLS/Xray-core #6242/#6248 family). Verified loopback e2e with hub-generated configs on 26.11.9<->26.11.9 and 26.11.9<->26.7.28: portal entry-* -> reverse mux -> router-admin redirect = HTTP 200 over pinned TLS. - hub: OWRT_REMOTE_TRANSPORT=tls|reality|none (default tls); generates self-signed cert (openssl) + exposes pin; serves tls streamSettings. - agent: uci tls_sni/tls_pin, validation, tls branch in render_client_config. - CGI: reality_short_id/tls_sni/tls_pin fields; uci config lines extended. - docs: REALITY_TRANSPORT.md extended with the bisect results and pitfalls (freedom finalRules for reverse egress, bridge registers ~2s late, legacy reverse objects removed).
This commit is contained in:
1 parent
d482ed97c4
commit
05972f8c24
6 files changed
+150
-10
No files matched your search
@@ -45,3 +45,41 @@ env хаба: `OWRT_REMOTE_REALITY_DEST=download.windowsupdate.com`, реста
|
||||
роутера продолжит писать `security=none`, роутер-агент умеет оба).
|
||||
Старые агенты (без полей security) не работают с reality-hub — роутер нужно обновить
|
||||
(установить ipk/файлы этого форка).
|
||||
|
||||
|
||||
## 22.11.2026: reverse + REALITY is broken on modern cores — `security=tls` is now the default
|
||||
|
||||
Bisect matrix (xray 26.7.28 / 26.11.9, all four pairs, loopback e2e):
|
||||
|
||||
* the REALITY hop itself authenticates and tunnels user traffic fine
|
||||
(shortId MUST be present in the client `realitySettings`; camo dest
|
||||
`www.microsoft.com` is dead because Microsoft now serves post-quantum
|
||||
cert chains — use `www.cloudflare.com`);
|
||||
* BUT the tag-form VLESS reverse (Rvs control channel, PR #5101) never
|
||||
registers when the bridge transport is REALITY: portal logs the reality
|
||||
handshake (`hs.c.conn == conn: true`) and then silence — no
|
||||
`v1.rvs.cool` request is ever dispatched. Upstream reports of the same
|
||||
family: XTLS/Xray-core #6242 / #6248 ("reverse broken since 26.5,
|
||||
works on 26.4.25"). Our repro: relay hex-dump shows the bridge's Rvs
|
||||
request on the wire, portal never responds.
|
||||
|
||||
Working alternative shipped as `OWRT_REMOTE_TRANSPORT=tls` (default):
|
||||
self-signed hub cert (hub generates it with openssl) + `pinnedPeerCertSha256`
|
||||
on the router (xray removed `allowInsecure`), ALPN `h2,http/1.1`, uTLS
|
||||
`fingerprint: chrome`. Verified end-to-end through hub-generated configs:
|
||||
portal `entry-*` -> reverse mux -> router `router-admin` freedom redirect
|
||||
= HTTP 200 on 26.11.9<->26.11.9 and 26.11.9<->26.7.28.
|
||||
|
||||
Pitfalls discovered along the way:
|
||||
|
||||
* freedom outbounds behind the reverse bridge need explicit
|
||||
`finalRules: [{action: allow, network: tcp, port: ...}]` — newer cores
|
||||
blackhole reverse egress by default (see also 3x-ui 6f6c7fc);
|
||||
* the Rvs bridge registers ~2 s after the router xray starts (monitor
|
||||
interval), healthcheck scripts must wait, or they see
|
||||
`non existing outTag`;
|
||||
* legacy `reverse.bridges/portals` config objects were REMOVED in 26.x —
|
||||
only the tag form works.
|
||||
|
||||
REALITY stays selectable (`OWRT_REMOTE_TRANSPORT=reality`) for the hub
|
||||
panel hop style until upstream fixes reverse-over-REALITY.
|
||||
@@ -21,6 +21,8 @@ config remote 'main'
|
||||
option reality_public_key ''
|
||||
option reality_server_name ''
|
||||
option reality_fingerprint 'chrome'
|
||||
option tls_sni ''
|
||||
option tls_pin ''
|
||||
option reverse_tag 'reverse-in'
|
||||
option ssh_vless_uuid ''
|
||||
option ssh_reverse_tag 'reverse-in-ssh'
|
||||
|
||||
@@ -705,6 +705,8 @@ render_client_config() (
|
||||
reality_sid="$(uci_get reality_short_id '')"
|
||||
reality_sni="$(uci_get reality_server_name '')"
|
||||
reality_fp="$(uci_get reality_fingerprint chrome)"
|
||||
tls_sni="$(uci_get tls_sni '')"
|
||||
tls_pin="$(uci_get tls_pin '')"
|
||||
reverse_tag="$(uci_get reverse_tag reverse-in)"
|
||||
ssh_reverse_tag="$(uci_get ssh_reverse_tag "${reverse_tag}-ssh")"
|
||||
admin_host="$(uci_get admin_host 127.0.0.1)"
|
||||
@@ -729,8 +731,17 @@ render_client_config() (
|
||||
fi
|
||||
done
|
||||
case "$vps_host" in *://*|*/*) die "vps_host должен содержать IP или домен без http(s):// и пути" ;; esac
|
||||
case "$security" in none|reality) ;; *) die "security: ожидается none или reality" ;; esac
|
||||
if [ "$security" = reality ]; then
|
||||
case "$security" in none|reality|tls) ;; *) die "security: ожидается none, reality или tls" ;; esac
|
||||
if [ "$security" = tls ]; then
|
||||
case "$tls_sni" in ''|*://*) die "tls_sni: SNI-домен хаба без схемы и путей" ;; esac
|
||||
if [ "$(printf '%s' "$tls_sni" | LC_ALL=C tr -d '\001-\040\177')" != "$tls_sni" ]; then
|
||||
die "tls_sni: содержит пробел или управляющий символ"
|
||||
fi
|
||||
case "$tls_pin" in *[!0-9a-fA-F]*|'') die "tls_pin: 64-символьный hex SHA256 сертификата хаба из карточки роутера на VPS" ;; esac
|
||||
[ "${#tls_pin}" -eq 64 ] || die "tls_pin: длина SHA256 должна быть 64 hex-символа"
|
||||
transport_stream='"security": "tls",
|
||||
"tlsSettings": {"serverName": "'"$(json_escape "$tls_sni")"'", "pinnedPeerCertSha256": "'"$(json_escape "$tls_pin")"'", "alpn": ["h2", "http/1.1"], "fingerprint": "'"$(json_escape "$reality_fp")"'"}'
|
||||
elif [ "$security" = reality ]; then
|
||||
case "$reality_pk" in ''|*[!A-Za-z0-9_-]*) die "reality_public_key: ожидается 43-символьный base64url-ключ X25519 из карточки роутера на VPS" ;; esac
|
||||
[ "${#reality_pk}" -eq 43 ] || die "reality_public_key: длина ключа X25519 должна быть 43 символа"
|
||||
case "$reality_sni" in ''|*://*) die "reality_server_name: укажите camouflage-домен без схемы и путей (например www.microsoft.com)" ;; esac
|
||||
|
||||
@@ -192,7 +192,7 @@ save_config() {
|
||||
fi
|
||||
uci_set enabled "$enabled"
|
||||
|
||||
for field in router_id router_name role hub_url hub_token heartbeat_interval xray_bin xray_config vps_host vps_port vless_uuid vless_encryption vless_flow security reality_public_key reality_server_name reality_fingerprint reverse_tag ssh_vless_uuid ssh_reverse_tag admin_host admin_port ssh_host ssh_port public_url; do
|
||||
for field in router_id router_name role hub_url hub_token heartbeat_interval xray_bin xray_config vps_host vps_port vless_uuid vless_encryption vless_flow security reality_public_key reality_short_id reality_server_name reality_fingerprint tls_sni tls_pin reverse_tag ssh_vless_uuid ssh_reverse_tag admin_host admin_port ssh_host ssh_port public_url; do
|
||||
uci_set "$field" "$(param "$field")"
|
||||
done
|
||||
if has_param vps_host_auto; then uci_set vps_host_mode auto; else uci_set vps_host_mode manual; fi
|
||||
@@ -208,7 +208,7 @@ save_config() {
|
||||
|
||||
clear_config() {
|
||||
local field
|
||||
for field in role public_url hub_url hub_token heartbeat_interval xray_bin xray_config vps_host vps_host_mode wan_direct wan_interface wan_dns vps_port vless_uuid vless_encryption vless_flow security reality_public_key reality_server_name reality_fingerprint reverse_tag ssh_vless_uuid ssh_reverse_tag admin_host admin_port ssh_host ssh_port; do
|
||||
for field in role public_url hub_url hub_token heartbeat_interval xray_bin xray_config vps_host vps_host_mode wan_direct wan_interface wan_dns vps_port vless_uuid vless_encryption vless_flow security reality_public_key reality_short_id reality_server_name reality_fingerprint tls_sni tls_pin reverse_tag ssh_vless_uuid ssh_reverse_tag admin_host admin_port ssh_host ssh_port; do
|
||||
uci -q delete "owrtremote.main.$field"
|
||||
done
|
||||
uci commit owrtremote
|
||||
@@ -715,7 +715,10 @@ EOF
|
||||
field vless_uuid "VLESS UUID" text "Уникальный UUID роутера. Бери из карточки роутера на VPS или из команды print-openwrt-config."
|
||||
field vless_encryption "VLESS encryption" text "Для этой схемы оставь none. Меняй только если сам меняешь Xray-конфиг на VPS."
|
||||
field vless_flow "VLESS flow" text "Обычно оставь пустым. Нужно только для специальных режимов Xray."
|
||||
field security "Транспорт (security)" text "none или reality. reality — TLS-упаковка VLESS (рекомендуется). Остальные значения — из карточки роутера на VPS."
|
||||
field security "Транспорт (security)" text "tls (рекомендуется), reality или none. Остальные значения — из карточки роутера на VPS."
|
||||
field reality_short_id "Reality shortId" text "8 hex-символов. Только для security=reality."
|
||||
field tls_sni "TLS SNI" text "SNI/CN сертификата хаба. Только для security=tls."
|
||||
field tls_pin "TLS pin" text "64 hex-символа SHA256 сертификата хаба. Только для security=tls."
|
||||
field reality_public_key "Reality public key" text "43-символьный публичный ключ X25519 хаба. Только для security=reality."
|
||||
field reality_server_name "Reality SNI" text "Camouflage-домен хаба, например www.microsoft.com. Только для security=reality."
|
||||
field reality_fingerprint "Reality fingerprint" text "Отпечаток клиента: chrome, firefox, safari, ios или android."
|
||||
|
||||
@@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-owrt-remote
|
||||
PKG_VERSION:=122
|
||||
PKG_RELEASE:=3
|
||||
PKG_RELEASE:=4
|
||||
PKG_LICENSE:=MIT
|
||||
PKG_MAINTAINER:=kzolotarev95
|
||||
PKGARCH:=all
|
||||
|
||||
+90
-4
@@ -119,8 +119,17 @@ DEFAULT_VLESS_PORT = int(os.environ.get("OWRT_REMOTE_VLESS_PORT", "8443"))
|
||||
# LuCI credentials and logs travel in cleartext inside that hop. This fork wraps
|
||||
# it in VLESS+Reality: a real TLS handshake camouflaged against a public dest,
|
||||
# no CA-issued certificates, no renewal. Per-router UUIDs still authenticate.
|
||||
# Set OWRT_REMOTE_TRANSPORT=none to fall back to upstream behavior.
|
||||
TRANSPORT_MODE = os.environ.get("OWRT_REMOTE_TRANSPORT", "reality").strip().lower()
|
||||
# OWRT_REMOTE_TRANSPORT: tls (default) | reality | none.
|
||||
# tls - self-signed hub cert + pinnedPeerCertSha256 on the router.
|
||||
# Works with the modern tag-form VLESS reverse on xray >= 26.5.
|
||||
# reality - REALITY camouflage. NOTE: tag-form reverse (Rvs control channel)
|
||||
# does NOT register over REALITY on xray 26.7.28/26.11.9
|
||||
# (XTLS/Xray-core #6242/#6248 family); verified broken in e2e
|
||||
# 22.11.2026. The hop itself authenticates fine, so keep this
|
||||
# switch ready for when upstream fixes reverse-over-REALITY.
|
||||
# none - upstream behavior (cleartext hop).
|
||||
TRANSPORT_MODE = os.environ.get("OWRT_REMOTE_TRANSPORT", "tls").strip().lower()
|
||||
TLS_SNI = os.environ.get("OWRT_REMOTE_TLS_SNI", "www.microsoft.com").strip()
|
||||
# NOTE: do NOT default to www.microsoft.com — Microsoft now serves post-quantum
|
||||
# (ML-DSA) cert chains and REALITY cannot re-sign them; the handshake silently
|
||||
# falls back to passthrough ("received real certificate"). Verified working
|
||||
@@ -4664,17 +4673,56 @@ def generate_reality_profile():
|
||||
}
|
||||
|
||||
|
||||
def generate_tls_profile():
|
||||
# Self-signed cert via the openssl CLI (stdlib cannot sign). The router
|
||||
# pins the leaf certificate hash (pinnedPeerCertSha256); allowInsecure
|
||||
# was removed from xray >= 26.x, pinning is the supported replacement.
|
||||
import hashlib
|
||||
binary = shutil.which("openssl") or ""
|
||||
if not binary:
|
||||
raise RuntimeError("openssl not found for TLS transport generation")
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
crt = os.path.join(tmp, "hub.crt")
|
||||
key = os.path.join(tmp, "hub.key")
|
||||
result = subprocess.run(
|
||||
[binary, "req", "-x509", "-newkey", "rsa:2048", "-nodes", "-days", "3650",
|
||||
"-subj", f"/CN={TLS_SNI}", "-addext", f"subjectAltName=DNS:{TLS_SNI}",
|
||||
"-keyout", key, "-out", crt],
|
||||
text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=60, check=False,
|
||||
)
|
||||
if result.returncode != 0:
|
||||
raise RuntimeError(f"openssl cert generation failed: {(result.stderr or '').strip()[:300]}")
|
||||
cert_pem = open(crt, encoding="utf-8").read()
|
||||
key_pem = open(key, encoding="utf-8").read()
|
||||
der = subprocess.run(
|
||||
[binary, "x509", "-in", crt, "-outform", "der"],
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=30, check=True,
|
||||
).stdout
|
||||
return {
|
||||
"mode": "tls",
|
||||
"serverName": TLS_SNI,
|
||||
"certificate": cert_pem,
|
||||
"key": key_pem,
|
||||
"pin": hashlib.sha256(der).hexdigest(),
|
||||
"fingerprint": "chrome",
|
||||
}
|
||||
|
||||
|
||||
def transport_profile():
|
||||
if TRANSPORT_MODE != "reality":
|
||||
if TRANSPORT_MODE not in ("reality", "tls"):
|
||||
return {"mode": "none"}
|
||||
if TRANSPORT_FILE.exists():
|
||||
try:
|
||||
data = json.loads(TRANSPORT_FILE.read_text(encoding="utf-8"))
|
||||
if data.get("mode") == "reality" and data.get("privateKey") and data.get("publicKey"):
|
||||
if TRANSPORT_MODE == "reality":
|
||||
return data
|
||||
if data.get("mode") == "tls" and data.get("certificate") and data.get("key") and data.get("pin"):
|
||||
if TRANSPORT_MODE == "tls":
|
||||
return data
|
||||
except (OSError, ValueError):
|
||||
pass
|
||||
data = generate_reality_profile()
|
||||
data = generate_tls_profile() if TRANSPORT_MODE == "tls" else generate_reality_profile()
|
||||
TRANSPORT_FILE.parent.mkdir(parents=True, exist_ok=True)
|
||||
atomic_write_text(TRANSPORT_FILE, json.dumps(data, ensure_ascii=False, indent=2) + "\n", mode=0o600)
|
||||
try:
|
||||
@@ -4686,6 +4734,13 @@ def transport_profile():
|
||||
|
||||
def transport_public_summary():
|
||||
profile = transport_profile()
|
||||
if profile.get("mode") == "tls":
|
||||
return {
|
||||
"mode": "tls",
|
||||
"serverName": profile["serverName"],
|
||||
"pin": profile["pin"],
|
||||
"fingerprint": profile.get("fingerprint", "chrome"),
|
||||
}
|
||||
if profile.get("mode") != "reality":
|
||||
return {"mode": "none"}
|
||||
return {
|
||||
@@ -4699,6 +4754,18 @@ def transport_public_summary():
|
||||
|
||||
def transport_server_stream():
|
||||
profile = transport_profile()
|
||||
if profile.get("mode") == "tls":
|
||||
return {
|
||||
"network": "tcp",
|
||||
"security": "tls",
|
||||
"tlsSettings": {
|
||||
"certificates": [{
|
||||
"certificate": [profile["certificate"]],
|
||||
"key": [profile["key"]],
|
||||
}],
|
||||
"alpn": ["h2", "http/1.1"],
|
||||
},
|
||||
}
|
||||
if profile.get("mode") != "reality":
|
||||
return {"network": "tcp", "security": "none"}
|
||||
return {
|
||||
@@ -4717,6 +4784,17 @@ def transport_server_stream():
|
||||
|
||||
def transport_client_stream():
|
||||
profile = transport_profile()
|
||||
if profile.get("mode") == "tls":
|
||||
return {
|
||||
"network": "tcp",
|
||||
"security": "tls",
|
||||
"tlsSettings": {
|
||||
"serverName": profile["serverName"],
|
||||
"pinnedPeerCertSha256": profile["pin"],
|
||||
"alpn": ["h2", "http/1.1"],
|
||||
"fingerprint": profile.get("fingerprint", "chrome"),
|
||||
},
|
||||
}
|
||||
if profile.get("mode") != "reality":
|
||||
return {"network": "tcp", "security": "none"}
|
||||
return {
|
||||
@@ -5068,6 +5146,11 @@ def build_openwrt_config_payload(row, hub_url, vps_host_override="", public_url_
|
||||
"public_url": effective_public_url,
|
||||
}
|
||||
profile = transport_profile()
|
||||
if profile.get("mode") == "tls":
|
||||
payload["security"] = "tls"
|
||||
payload["tls_sni"] = profile["serverName"]
|
||||
payload["tls_pin"] = profile["pin"]
|
||||
payload["reality_fingerprint"] = profile.get("fingerprint", "chrome")
|
||||
if profile.get("mode") == "reality":
|
||||
payload["security"] = "reality"
|
||||
payload["reality_public_key"] = profile["publicKey"]
|
||||
@@ -5111,8 +5194,11 @@ def build_openwrt_config_lines(payload, mode="manual"):
|
||||
f"uci set owrtremote.main.public_url='{sh_quote(payload['public_url'])}'",
|
||||
f"uci set owrtremote.main.security='{sh_quote(payload.get('security', 'none'))}'",
|
||||
f"uci set owrtremote.main.reality_public_key='{sh_quote(payload.get('reality_public_key', ''))}'",
|
||||
f"uci set owrtremote.main.reality_short_id='{sh_quote(payload.get('reality_short_id', ''))}'",
|
||||
f"uci set owrtremote.main.reality_server_name='{sh_quote(payload.get('reality_server_name', ''))}'",
|
||||
f"uci set owrtremote.main.reality_fingerprint='{sh_quote(payload.get('reality_fingerprint', ''))}'",
|
||||
f"uci set owrtremote.main.tls_sni='{sh_quote(payload.get('tls_sni', ''))}'",
|
||||
f"uci set owrtremote.main.tls_pin='{sh_quote(payload.get('tls_pin', ''))}'",
|
||||
"uci commit owrtremote",
|
||||
"owrt-remote render-client",
|
||||
"/etc/init.d/owrt-remote enable",
|
||||
|
||||
Reference in new issue
Block a user