From 4b97309ba1093cbe4742e4f00250def0c4a4e341 Mon Sep 17 00:00:00 2001 From: xream Date: Sat, 20 Jun 2026 10:25:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20sing-box=20ss+shado?= =?UTF-8?q?w-tls=20=E6=80=BB=E6=98=AF=E8=BE=93=E5=87=BA=20utls=20=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/package.json | 2 +- .../core/proxy-utils/producers/sing-box.js | 10 +++-- .../test/proxy-producers/structured.spec.js | 40 +++++++++++++++---- 3 files changed, 40 insertions(+), 12 deletions(-) diff --git a/backend/package.json b/backend/package.json index 6c566ba5..7f5593cf 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.28.0", + "version": "2.28.1", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.", "main": "src/main.js", "packageManager": "pnpm@11.0.9", diff --git a/backend/src/core/proxy-utils/producers/sing-box.js b/backend/src/core/proxy-utils/producers/sing-box.js index db5c79f8..33c708e6 100644 --- a/backend/src/core/proxy-utils/producers/sing-box.js +++ b/backend/src/core/proxy-utils/producers/sing-box.js @@ -568,12 +568,14 @@ const shadowTLSOutboundParser = (proxy = {}, pluginOpts) => { tls: { enabled: true, server_name: pluginOpts.host, - utls: { - enabled: true, - fingerprint, - }, }, }; + if (fingerprint) { + stPart.tls.utls = { + enabled: true, + fingerprint, + }; + } if (stPart.server_port < 0 || stPart.server_port > 65535) throw '端口值非法'; const alpn = normalizeALPN(pluginOpts.alpn); diff --git a/backend/src/test/proxy-producers/structured.spec.js b/backend/src/test/proxy-producers/structured.spec.js index 0fa114a7..2219df48 100644 --- a/backend/src/test/proxy-producers/structured.spec.js +++ b/backend/src/test/proxy-producers/structured.spec.js @@ -514,15 +514,13 @@ describe('Proxy structured producers', function () { tls: { enabled: true, server_name: 'mask.example.com', - utls: { - enabled: true, - }, }, domain_resolver: { server: 'dns-out', strategy: 'ipv6_only', }, }); + expect(output.outbounds[1].tls).to.not.have.property('utls'); }); it('exports parsed Surge Snell shadow-tls lines to sing-box chained outbounds', function () { @@ -648,6 +646,36 @@ describe('Proxy structured producers', function () { }); }); + it('does not emit sing-box ShadowTLS uTLS without client fingerprint', function () { + const [proxy] = ProxyUtils.parse(`proxies: + - name: SS ShadowTLS No Fingerprint + type: ss + server: ss.example.com + port: 443 + cipher: 2022-blake3-aes-128-gcm + password: password + udp-over-tcp: true + udp-over-tcp-version: 2 + plugin: shadow-tls + plugin-opts: + host: gateway.icloud.com + password: shadow_tls_password + version: 3`); + + const output = loadProducedJson('sing-box', proxy); + const shadowtls = output.outbounds.find( + (item) => item.tag === 'SS ShadowTLS No Fingerprint_shadowtls', + ); + + expectSubset(shadowtls, { + tls: { + enabled: true, + server_name: 'gateway.icloud.com', + }, + }); + expect(shadowtls.tls).to.not.have.property('utls'); + }); + it('omits unsupported sing-box ShadowTLS uTLS fingerprints', function () { const [proxy] = ProxyUtils.parse(`proxies: - name: SS ShadowTLS Unsupported Fingerprint @@ -672,12 +700,10 @@ describe('Proxy structured producers', function () { expectSubset(shadowtls, { tls: { enabled: true, - utls: { - enabled: true, - }, + server_name: 'cloud.tencent.com', }, }); - expect(shadowtls.tls.utls).to.not.have.property('fingerprint'); + expect(shadowtls.tls).to.not.have.property('utls'); }); it('keeps only Shadowsocks shadow-tls versions 1 through 3 for Mihomo', function () {