Skip to content

Commit 0882a52

Browse files
committed
feat: 未显式关闭 udp 的情况下, 视为开启 udp
1 parent 662c433 commit 0882a52

5 files changed

Lines changed: 23 additions & 5 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.36.6",
3+
"version": "2.36.7",
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/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,9 @@ function formatTransportPath(path) {
718718
}
719719

720720
function lastParse(proxy) {
721+
proxy.udp = ![false, 0, '0', 'false', 'off'].includes(
722+
typeof proxy.udp === 'string' ? proxy.udp.toLowerCase() : proxy.udp,
723+
);
721724
if (typeof proxy.cipher === 'string') {
722725
proxy.cipher = proxy.cipher.toLowerCase();
723726
}

backend/src/test/proxy-parsers/v2ray-and-platforms.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe('VMess and VLESS parser coverage', function () {
1919
port: 443,
2020
cipher: 'auto',
2121
uuid: UUID,
22-
udp: 'true',
22+
udp: true,
2323
tfo: 'true',
2424
'skip-cert-verify': false,
2525
});

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,21 @@ describe('Proxy structured producers', function () {
107107
expect(output.proxies[0]).to.not.have.property('_loon_tls_profile');
108108
});
109109

110+
it('defaults omitted UDP to true while preserving explicit disablement', function () {
111+
const [enabled, disabled] = ProxyUtils.parse(
112+
'Surge AnyTLS=anytls,anytls.example.com,443,password=secret\nanytls=anytls.example.com:443,password=secret,udp-relay=false,tag=QX AnyTLS No UDP',
113+
);
114+
115+
expect(enabled.udp).to.equal(true);
116+
const output = loadProducedYaml('Mihomo', [enabled, disabled]).proxies;
117+
expect(
118+
output.find((proxy) => proxy.name === enabled.name).udp,
119+
).to.equal(true);
120+
expect(
121+
output.find((proxy) => proxy.name === disabled.name).udp,
122+
).to.equal(false);
123+
});
124+
110125
it('normalizes VMess security values for documented target platforms', function () {
111126
const invalidSecurityProxy = {
112127
type: 'vmess',

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ describe('Proxy text producers', function () {
875875
const output = produceExternal('Loon', proxy);
876876

877877
expect(output).to.equal(
878-
'URI Hysteria2=Hysteria2,hy2.example.com,443,"secret",server-ports="1000,2000-3000,5000",hop-interval=30,tls-name=hy2.example.com,skip-cert-verify=false,fast-open=false',
878+
'URI Hysteria2=Hysteria2,hy2.example.com,443,"secret",server-ports="1000,2000-3000,5000",hop-interval=30,tls-name=hy2.example.com,skip-cert-verify=false,fast-open=false,udp=true',
879879
);
880880
});
881881

@@ -1385,8 +1385,8 @@ describe('Proxy text producers', function () {
13851385
const output = ProxyUtils.produce(proxies, 'Surge', 'external');
13861386

13871387
expect(output.split('\n')).to.deep.equal([
1388-
`Surge H2 Round Trip=h2-connect,h2.example.com,443,headers="X-Padding:"<random-string(16-32)>"",max-streams=1,sni="sni.example.com"`,
1389-
`Surge Trust Round Trip=trust-tunnel,trust.example.com,443,username="user",password="pass",headers="X-Client:"Surge"",max-streams=3,sni="sni.example.com"`,
1388+
`Surge H2 Round Trip=h2-connect,h2.example.com,443,headers="X-Padding:"<random-string(16-32)>"",max-streams=1,sni="sni.example.com",udp-relay=true`,
1389+
`Surge Trust Round Trip=trust-tunnel,trust.example.com,443,username="user",password="pass",headers="X-Client:"Surge"",max-streams=3,sni="sni.example.com",udp-relay=true`,
13901390
]);
13911391
});
13921392

0 commit comments

Comments
 (0)