Skip to content

Commit 4b97309

Browse files
committed
fix: 修复 sing-box ss+shadow-tls 总是输出 utls 的问题
1 parent 24f1aa8 commit 4b97309

3 files changed

Lines changed: 40 additions & 12 deletions

File tree

backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sub-store",
3-
"version": "2.28.0",
3+
"version": "2.28.1",
44
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
55
"main": "src/main.js",
66
"packageManager": "pnpm@11.0.9",

backend/src/core/proxy-utils/producers/sing-box.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -568,12 +568,14 @@ const shadowTLSOutboundParser = (proxy = {}, pluginOpts) => {
568568
tls: {
569569
enabled: true,
570570
server_name: pluginOpts.host,
571-
utls: {
572-
enabled: true,
573-
fingerprint,
574-
},
575571
},
576572
};
573+
if (fingerprint) {
574+
stPart.tls.utls = {
575+
enabled: true,
576+
fingerprint,
577+
};
578+
}
577579
if (stPart.server_port < 0 || stPart.server_port > 65535)
578580
throw '端口值非法';
579581
const alpn = normalizeALPN(pluginOpts.alpn);

backend/src/test/proxy-producers/structured.spec.js

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -514,15 +514,13 @@ describe('Proxy structured producers', function () {
514514
tls: {
515515
enabled: true,
516516
server_name: 'mask.example.com',
517-
utls: {
518-
enabled: true,
519-
},
520517
},
521518
domain_resolver: {
522519
server: 'dns-out',
523520
strategy: 'ipv6_only',
524521
},
525522
});
523+
expect(output.outbounds[1].tls).to.not.have.property('utls');
526524
});
527525

528526
it('exports parsed Surge Snell shadow-tls lines to sing-box chained outbounds', function () {
@@ -648,6 +646,36 @@ describe('Proxy structured producers', function () {
648646
});
649647
});
650648

649+
it('does not emit sing-box ShadowTLS uTLS without client fingerprint', function () {
650+
const [proxy] = ProxyUtils.parse(`proxies:
651+
- name: SS ShadowTLS No Fingerprint
652+
type: ss
653+
server: ss.example.com
654+
port: 443
655+
cipher: 2022-blake3-aes-128-gcm
656+
password: password
657+
udp-over-tcp: true
658+
udp-over-tcp-version: 2
659+
plugin: shadow-tls
660+
plugin-opts:
661+
host: gateway.icloud.com
662+
password: shadow_tls_password
663+
version: 3`);
664+
665+
const output = loadProducedJson('sing-box', proxy);
666+
const shadowtls = output.outbounds.find(
667+
(item) => item.tag === 'SS ShadowTLS No Fingerprint_shadowtls',
668+
);
669+
670+
expectSubset(shadowtls, {
671+
tls: {
672+
enabled: true,
673+
server_name: 'gateway.icloud.com',
674+
},
675+
});
676+
expect(shadowtls.tls).to.not.have.property('utls');
677+
});
678+
651679
it('omits unsupported sing-box ShadowTLS uTLS fingerprints', function () {
652680
const [proxy] = ProxyUtils.parse(`proxies:
653681
- name: SS ShadowTLS Unsupported Fingerprint
@@ -672,12 +700,10 @@ describe('Proxy structured producers', function () {
672700
expectSubset(shadowtls, {
673701
tls: {
674702
enabled: true,
675-
utls: {
676-
enabled: true,
677-
},
703+
server_name: 'cloud.tencent.com',
678704
},
679705
});
680-
expect(shadowtls.tls.utls).to.not.have.property('fingerprint');
706+
expect(shadowtls.tls).to.not.have.property('utls');
681707
});
682708

683709
it('keeps only Shadowsocks shadow-tls versions 1 through 3 for Mihomo', function () {

0 commit comments

Comments
 (0)