diff --git a/backend/package.json b/backend/package.json index 32144139..078ec140 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.21.91", + "version": "2.21.92", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.", "main": "src/main.js", "scripts": { diff --git a/backend/src/core/proxy-utils/parsers/peggy/qx.js b/backend/src/core/proxy-utils/parsers/peggy/qx.js index 235c9b44..2007f52a 100644 --- a/backend/src/core/proxy-utils/parsers/peggy/qx.js +++ b/backend/src/core/proxy-utils/parsers/peggy/qx.js @@ -39,6 +39,12 @@ const grammars = String.raw` $set(proxy, "ws-opts.headers.Host", obfs.host); } else if (obfs.type === "over-tls") { proxy.tls = true; + // Some QX share links use obfs-host as the TLS server name for + // plain over-tls TCP nodes instead of the explicit tls-host field. + // Accept it as a compatibility alias, but do not override tls-host. + if (obfs.host && !proxy.sni) { + proxy.sni = obfs.host; + } } else if (obfs.type === "http") { proxy.network = "http"; $set(proxy, "http-opts.path", obfs.path); diff --git a/backend/src/test/proxy-parsers/v2ray-and-platforms.spec.js b/backend/src/test/proxy-parsers/v2ray-and-platforms.spec.js index efa3abd3..d14c2208 100644 --- a/backend/src/test/proxy-parsers/v2ray-and-platforms.spec.js +++ b/backend/src/test/proxy-parsers/v2ray-and-platforms.spec.js @@ -1101,6 +1101,44 @@ describe('Platform raw-format parser coverage', function () { }, }, }, + { + title: 'parses vless over-tls lines using obfs-host as the tls server name alias', + input: `vless=qx-vless-overtls.example.com:37001,method=none,password=${UUID},obfs=over-tls,obfs-host=tls-name.example.com,tls13=true,tls-verification=false,reality-base64-pubkey=pubkey,reality-hex-shortid=01ab,vless-flow=xtls-rprx-vision,fast-open=false,udp-relay=true,tag=QX VLESS Over TLS Alias`, + expected: { + type: 'vless', + name: 'QX VLESS Over TLS Alias', + server: 'qx-vless-overtls.example.com', + port: 37001, + cipher: 'none', + uuid: UUID, + tls: true, + sni: 'tls-name.example.com', + 'skip-cert-verify': true, + flow: 'xtls-rprx-vision', + udp: true, + tfo: false, + 'reality-opts': { + 'public-key': 'pubkey', + 'short-id': '01ab', + }, + }, + }, + { + title: 'prefers explicit tls-host over obfs-host for vless over-tls lines', + input: `vless=qx-vless-overtls-priority.example.com:443,method=none,password=${UUID},obfs=over-tls,obfs-host=tls-alias.example.com,tls-host=explicit-sni.example.com,tls-verification=false,vless-flow=xtls-rprx-vision,tag=QX VLESS Over TLS Explicit`, + expected: { + type: 'vless', + name: 'QX VLESS Over TLS Explicit', + server: 'qx-vless-overtls-priority.example.com', + port: 443, + cipher: 'none', + uuid: UUID, + tls: true, + sni: 'explicit-sni.example.com', + 'skip-cert-verify': true, + flow: 'xtls-rprx-vision', + }, + }, { title: 'parses trojan websocket tls lines', input: 'trojan=qx-trojan.example.com:443,password=secret,obfs=wss,obfs-host=cdn.example.com,obfs-uri=/trojan,tls-verification=false,tls-host=sni.example.com,tls-cert-sha256=fingerprint,tag=QX Trojan',