diff --git a/backend/package.json b/backend/package.json index 2c25f309..2abbdc5c 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.21.68", + "version": "2.21.69", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.", "main": "src/main.js", "scripts": { diff --git a/backend/src/core/proxy-utils/producers/stash.js b/backend/src/core/proxy-utils/producers/stash.js index fdf6cb9d..0f2197b6 100644 --- a/backend/src/core/proxy-utils/producers/stash.js +++ b/backend/src/core/proxy-utils/producers/stash.js @@ -45,10 +45,14 @@ export default function Stash_Producer() { '2022-blake3-aes-128-gcm', '2022-blake3-aes-256-gcm', ].includes(proxy.cipher)) || - (proxy.type === 'snell' && proxy.version >= 4) || - (proxy.type === 'vless' && - proxy['reality-opts'] && - !['xtls-rprx-vision'].includes(proxy.flow)) + (proxy.type === 'snell' && proxy.version >= 4) + ) { + return false; + } else if ( + ['vless'].includes(proxy.type) && + proxy['reality-opts'] && + proxy.network && + !['tcp'].includes(proxy.network) ) { return false; } else if ( diff --git a/backend/src/test/proxy-producers/structured.spec.js b/backend/src/test/proxy-producers/structured.spec.js index 89786816..709e736d 100644 --- a/backend/src/test/proxy-producers/structured.spec.js +++ b/backend/src/test/proxy-producers/structured.spec.js @@ -1,6 +1,7 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; +import { ProxyUtils } from '@/core/proxy-utils'; import { UUID, expectSubset, @@ -226,6 +227,230 @@ describe('Proxy structured producers', function () { }); }); + it('emits Stash VLESS TCP REALITY proxies without validating flow values', function () { + const proxy = { + type: 'vless', + name: 'Stash Reality Custom Flow', + server: 'vless.example.com', + port: 443, + uuid: UUID, + tls: true, + network: 'tcp', + flow: 'xtls-rprx-unknown', + sni: 'sni.example.com', + 'reality-opts': { + 'public-key': 'pubkey', + 'short-id': '08', + }, + }; + + const internal = produceInternal('Stash', proxy); + const external = loadProducedYaml('Stash', proxy); + + expect(internal).to.have.length(1); + expect(external.proxies).to.have.length(1); + expectSubset(internal[0], { + type: 'vless', + name: 'Stash Reality Custom Flow', + network: 'tcp', + flow: 'xtls-rprx-unknown', + servername: 'sni.example.com', + 'reality-opts': { + 'public-key': 'pubkey', + 'short-id': '08', + }, + }); + expectSubset(external.proxies[0], { + type: 'vless', + name: 'Stash Reality Custom Flow', + network: 'tcp', + flow: 'xtls-rprx-unknown', + servername: 'sni.example.com', + 'reality-opts': { + 'public-key': 'pubkey', + 'short-id': '08', + }, + }); + }); + + it('keeps default-tcp Stash VLESS REALITY proxies when network is omitted', function () { + const proxy = { + type: 'vless', + name: 'Implicit TCP Reality', + server: 'vless.example.com', + port: 443, + uuid: UUID, + tls: true, + sni: 'sni.example.com', + 'reality-opts': { + 'public-key': 'pubkey', + 'short-id': '08', + }, + }; + + const internal = produceInternal('Stash', proxy); + const external = loadProducedYaml('Stash', proxy); + + expect(internal).to.have.length(1); + expect(external.proxies).to.have.length(1); + expectSubset(internal[0], { + type: 'vless', + name: 'Implicit TCP Reality', + servername: 'sni.example.com', + 'reality-opts': { + 'public-key': 'pubkey', + 'short-id': '08', + }, + }); + expect(external.proxies[0]).to.not.have.property('network'); + }); + + it('keeps Stash VLESS TCP REALITY proxies when URI input omits flow', function () { + const proxies = ProxyUtils.parse( + `vless://${UUID}@vless.example.com:443?type=tcp&security=reality&sni=sni.example.com&pbk=pubkey&sid=08#No%20Flow`, + ); + + const internal = produceInternal('Stash', proxies); + const external = loadProducedYaml('Stash', proxies); + + expect(internal).to.have.length(1); + expect(external.proxies).to.have.length(1); + expect(internal[0]).to.not.have.property('flow'); + expectSubset(internal[0], { + type: 'vless', + name: 'No Flow', + network: 'tcp', + servername: 'sni.example.com', + 'reality-opts': { + 'public-key': 'pubkey', + 'short-id': '08', + }, + }); + expectSubset(external.proxies[0], { + type: 'vless', + name: 'No Flow', + network: 'tcp', + servername: 'sni.example.com', + 'reality-opts': { + 'public-key': 'pubkey', + 'short-id': '08', + }, + }); + }); + + it('keeps Stash VLESS TCP REALITY nodes while still filtering non-tcp and unsupported variants', function () { + const proxies = [ + { + type: 'vless', + name: 'Supported Reality', + server: 'vless.example.com', + port: 443, + uuid: UUID, + tls: true, + network: 'tcp', + 'reality-opts': { + 'public-key': 'pubkey', + 'short-id': '08', + }, + }, + { + type: 'vless', + name: 'Custom Flow', + server: 'unsupported-flow.example.com', + port: 443, + uuid: UUID, + tls: true, + network: 'tcp', + flow: 'xtls-rprx-unknown', + 'reality-opts': { + 'public-key': 'pubkey', + 'short-id': '08', + }, + }, + { + type: 'vless', + name: 'Reality WS', + server: 'vless-ws.example.com', + port: 443, + uuid: UUID, + tls: true, + network: 'ws', + 'ws-opts': { + path: '/ws', + headers: { + Host: 'cdn.example.com', + }, + }, + 'reality-opts': { + 'public-key': 'pubkey', + 'short-id': '08', + }, + }, + { + type: 'vless', + name: 'XHTTP', + server: 'vless-xhttp.example.com', + port: 443, + uuid: UUID, + tls: true, + network: 'xhttp', + 'xhttp-opts': { + path: '/xhttp', + }, + 'reality-opts': { + 'public-key': 'pubkey', + 'short-id': '08', + }, + }, + { + type: 'vless', + name: 'Encrypted VLESS', + server: 'encrypted.example.com', + port: 443, + uuid: UUID, + tls: true, + network: 'tcp', + encryption: 'aes-128-gcm', + 'reality-opts': { + 'public-key': 'pubkey', + 'short-id': '08', + }, + }, + ]; + + const internal = produceInternal('Stash', proxies); + const external = loadProducedYaml('Stash', proxies); + + expect(internal).to.have.length(2); + expect(external.proxies).to.have.length(2); + expect(internal.map((proxy) => proxy.name)).to.deep.equal([ + 'Supported Reality', + 'Custom Flow', + ]); + expect(external.proxies.map((proxy) => proxy.name)).to.deep.equal([ + 'Supported Reality', + 'Custom Flow', + ]); + expectSubset(internal[0], { + type: 'vless', + name: 'Supported Reality', + }); + expectSubset(internal[1], { + type: 'vless', + name: 'Custom Flow', + flow: 'xtls-rprx-unknown', + }); + expectSubset(external.proxies[0], { + type: 'vless', + name: 'Supported Reality', + }); + expectSubset(external.proxies[1], { + type: 'vless', + name: 'Custom Flow', + flow: 'xtls-rprx-unknown', + }); + }); + it('promotes shadow-tls fields for Shadowrocket', function () { const proxy = { type: 'ss',