feat: Surge 支持 Snell v6(v6 不支持 obfs, 将自动过滤)

This commit is contained in:
xream committed 2026-06-12 08:11:12 +08:00
1 parent 43225c0011
commit f89921ab30
3 files changed
+67 -19

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "sub-store",
"version": "2.24.17",
"version": "2.24.19",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
"main": "src/main.js",
"packageManager": "pnpm@11.0.9",
@@ -96,6 +96,18 @@ function warnMaxStreamsIfNeeded(proxy) {
);
}
function hasSnellObfs(proxy) {
return (
isPresent(proxy, 'obfs-opts.mode') ||
isPresent(proxy, 'obfs-opts.host') ||
isPresent(proxy, 'obfs-opts.path')
);
}
function isUnsupportedSnellV6Obfs(proxy) {
return Number(proxy.version) === 6 && hasSnellObfs(proxy);
}
export default function Surge_Producer() {
const produce = (proxy, type, opts = {}) => {
if (
@@ -923,6 +935,13 @@ function formatHeaderMap(headers, separator) {
}
function snell(proxy) {
if (isUnsupportedSnellV6Obfs(proxy)) {
$.error(
`Platform ${targetPlatform} does not support Snell version ${proxy.version} with obfs`,
);
return '';
}
const result = new Result(proxy);
result.append(`${proxy.name}=${proxy.type},${proxy.server},${proxy.port}`);
result.appendIfPresent(`,version=${proxy.version}`, 'version');
+47 -18
View File
@@ -807,6 +807,47 @@ describe('Proxy text producers', function () {
);
});
it('produces Surge Snell v6 and filters v6 obfs', function () {
const { result: output, errors } = captureErrors(() =>
ProxyUtils.produce(
[
{
type: 'snell',
name: 'Surge Snell v6',
server: 'snell.example.com',
port: 443,
psk: 'secret',
version: 6,
udp: true,
},
{
type: 'snell',
name: 'Surge Snell v6 Obfs',
server: 'snell.example.com',
port: 443,
psk: 'secret',
version: 6,
udp: true,
'obfs-opts': {
mode: 'tls',
host: 'obfs.example.com',
path: '/snell',
},
},
],
'Surge',
'external',
),
);
expect(output).to.equal(
'Surge Snell v6=snell,snell.example.com,443,version=6,psk="secret",udp-relay=true',
);
expect(errors).to.deep.equal([
'Platform Surge does not support Snell version 6 with obfs',
]);
});
it('omits Surge TLS-only params for plain HTTP, SOCKS5, and VMess nodes', function () {
const cases = [
{
@@ -2791,16 +2832,10 @@ describe('Proxy text producers', function () {
expect(
reparsed[0]['xhttp-opts']?.['download-settings']?.server,
).to.equal('download.example.com');
expect(reparsed[0]['xhttp-opts']?.['session-table']).to.equal(
'Base62',
);
expect(reparsed[0]['xhttp-opts']?.['session-length']).to.equal(
'16-32',
);
expect(reparsed[0]['xhttp-opts']?.['session-table']).to.equal('Base62');
expect(reparsed[0]['xhttp-opts']?.['session-length']).to.equal('16-32');
expect(
reparsed[0]['xhttp-opts']?.['download-settings']?.[
'session-table'
],
reparsed[0]['xhttp-opts']?.['download-settings']?.['session-table'],
).to.equal('abcXYZ012');
expect(
reparsed[0]['xhttp-opts']?.['download-settings']?.[
@@ -4407,12 +4442,8 @@ describe('Proxy text producers', function () {
expect(
reparsed[0]['xhttp-opts']?.['sc-min-posts-interval-ms'],
).to.equal('0-300');
expect(reparsed[0]['xhttp-opts']?.['session-table']).to.equal(
'Base62',
);
expect(reparsed[0]['xhttp-opts']?.['session-length']).to.equal(
'16-32',
);
expect(reparsed[0]['xhttp-opts']?.['session-table']).to.equal('Base62');
expect(reparsed[0]['xhttp-opts']?.['session-length']).to.equal('16-32');
expect(
reparsed[0]['xhttp-opts']?.['download-settings']?.[
'sc-max-each-post-bytes'
@@ -4424,9 +4455,7 @@ describe('Proxy text producers', function () {
],
).to.equal('0-300');
expect(
reparsed[0]['xhttp-opts']?.['download-settings']?.[
'session-table'
],
reparsed[0]['xhttp-opts']?.['download-settings']?.['session-table'],
).to.equal('abcXYZ012');
expect(
reparsed[0]['xhttp-opts']?.['download-settings']?.[