From 0882a5222913aa48d6509ef471a0185d7e07f3d9 Mon Sep 17 00:00:00 2001 From: xream Date: Wed, 15 Jul 2026 16:54:56 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9C=AA=E6=98=BE=E5=BC=8F=E5=85=B3?= =?UTF-8?q?=E9=97=AD=20udp=20=E7=9A=84=E6=83=85=E5=86=B5=E4=B8=8B,=20?= =?UTF-8?q?=E8=A7=86=E4=B8=BA=E5=BC=80=E5=90=AF=20udp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/package.json | 2 +- backend/src/core/proxy-utils/index.js | 3 +++ .../proxy-parsers/v2ray-and-platforms.spec.js | 2 +- .../src/test/proxy-producers/structured.spec.js | 15 +++++++++++++++ backend/src/test/proxy-producers/text.spec.js | 6 +++--- 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/backend/package.json b/backend/package.json index 7d9bc382..d23da6e3 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.36.6", + "version": "2.36.7", "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/index.js b/backend/src/core/proxy-utils/index.js index 8849e537..4fdfbf3f 100644 --- a/backend/src/core/proxy-utils/index.js +++ b/backend/src/core/proxy-utils/index.js @@ -718,6 +718,9 @@ function formatTransportPath(path) { } function lastParse(proxy) { + proxy.udp = ![false, 0, '0', 'false', 'off'].includes( + typeof proxy.udp === 'string' ? proxy.udp.toLowerCase() : proxy.udp, + ); if (typeof proxy.cipher === 'string') { proxy.cipher = proxy.cipher.toLowerCase(); } 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 75686f98..a6cf8ed5 100644 --- a/backend/src/test/proxy-parsers/v2ray-and-platforms.spec.js +++ b/backend/src/test/proxy-parsers/v2ray-and-platforms.spec.js @@ -19,7 +19,7 @@ describe('VMess and VLESS parser coverage', function () { port: 443, cipher: 'auto', uuid: UUID, - udp: 'true', + udp: true, tfo: 'true', 'skip-cert-verify': false, }); diff --git a/backend/src/test/proxy-producers/structured.spec.js b/backend/src/test/proxy-producers/structured.spec.js index 54c40f2a..65d99419 100644 --- a/backend/src/test/proxy-producers/structured.spec.js +++ b/backend/src/test/proxy-producers/structured.spec.js @@ -107,6 +107,21 @@ describe('Proxy structured producers', function () { expect(output.proxies[0]).to.not.have.property('_loon_tls_profile'); }); + it('defaults omitted UDP to true while preserving explicit disablement', function () { + const [enabled, disabled] = ProxyUtils.parse( + 'Surge AnyTLS=anytls,anytls.example.com,443,password=secret\nanytls=anytls.example.com:443,password=secret,udp-relay=false,tag=QX AnyTLS No UDP', + ); + + expect(enabled.udp).to.equal(true); + const output = loadProducedYaml('Mihomo', [enabled, disabled]).proxies; + expect( + output.find((proxy) => proxy.name === enabled.name).udp, + ).to.equal(true); + expect( + output.find((proxy) => proxy.name === disabled.name).udp, + ).to.equal(false); + }); + it('normalizes VMess security values for documented target platforms', function () { const invalidSecurityProxy = { type: 'vmess', diff --git a/backend/src/test/proxy-producers/text.spec.js b/backend/src/test/proxy-producers/text.spec.js index 920ca041..c94b6e3c 100644 --- a/backend/src/test/proxy-producers/text.spec.js +++ b/backend/src/test/proxy-producers/text.spec.js @@ -875,7 +875,7 @@ describe('Proxy text producers', function () { const output = produceExternal('Loon', proxy); expect(output).to.equal( - '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', + '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', ); }); @@ -1385,8 +1385,8 @@ describe('Proxy text producers', function () { const output = ProxyUtils.produce(proxies, 'Surge', 'external'); expect(output.split('\n')).to.deep.equal([ - `Surge H2 Round Trip=h2-connect,h2.example.com,443,headers="X-Padding:""",max-streams=1,sni="sni.example.com"`, - `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"`, + `Surge H2 Round Trip=h2-connect,h2.example.com,443,headers="X-Padding:""",max-streams=1,sni="sni.example.com",udp-relay=true`, + `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`, ]); });