Skip to content

Commit c4dd762

Browse files
committed
feat: Surge Snell v6.0.0b3 新增 mode 字段
1 parent 3cf333f commit c4dd762

5 files changed

Lines changed: 40 additions & 3 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.24.21",
3+
"version": "2.24.22",
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/parsers/peggy/surge.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ ssh = tag equals "ssh" address (username password)? (usernamek passwordk)? (serv
397397
proxy.type = "ssh";
398398
handleShadowTLS();
399399
}
400-
snell = tag equals "snell" address (snell_version/snell_psk/obfs/obfs_host/obfs_uri/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/udp_relay/reuse/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
400+
snell = tag equals "snell" address (snell_version/snell_mode/snell_psk/obfs/obfs_host/obfs_uri/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/udp_relay/reuse/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
401401
proxy.type = "snell";
402402
// handle obfs
403403
if (obfs.type == "http" || obfs.type === "tls") {
@@ -520,6 +520,12 @@ client_cert = comma "client-cert" equals match:[^,]+ { proxy["keystore-client-ce
520520
521521
snell_psk = comma "psk" equals match:[^,]+ { proxy.psk = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); }
522522
snell_version = comma "version" equals match:$[0-9]+ { proxy.version = parseInt(match.trim()); }
523+
snell_mode = comma "mode" equals match:[^,]+ {
524+
const mode = stripQuotes(match.join("")).trim();
525+
if (["default", "unshaped", "unsafe-raw"].includes(mode)) {
526+
proxy.mode = mode;
527+
}
528+
}
523529
524530
usernamek = comma "username" equals match:[^,]+ { proxy.username = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); }
525531
passwordk = comma "password" equals match:[^,]+ { proxy.password = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); }

backend/src/core/proxy-utils/producers/surge.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,9 @@ function snell(proxy) {
946946
result.append(`${proxy.name}=${proxy.type},${proxy.server},${proxy.port}`);
947947
result.appendIfPresent(`,version=${proxy.version}`, 'version');
948948
result.appendIfPresent(`,psk="${proxy.psk}"`, 'psk');
949+
if (Number(proxy.version) === 6) {
950+
result.appendIfPresent(`,mode=${proxy.mode}`, 'mode');
951+
}
949952

950953
const ip_version = ipVersions[proxy['ip-version']] || proxy['ip-version'];
951954
result.appendIfPresent(`,ip-version=${ip_version}`, 'ip-version');

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3655,6 +3655,20 @@ describe('Platform raw-format parser coverage', function () {
36553655
},
36563656
},
36573657
},
3658+
{
3659+
title: 'parses snell v6 mode lines',
3660+
input: 'Surge Snell v6 = snell,surge-snell.example.com,443,psk=secret,version=6,mode=unshaped,udp-relay=true',
3661+
expected: {
3662+
type: 'snell',
3663+
name: 'Surge Snell v6',
3664+
server: 'surge-snell.example.com',
3665+
port: 443,
3666+
psk: 'secret',
3667+
version: 6,
3668+
mode: 'unshaped',
3669+
udp: true,
3670+
},
3671+
},
36583672
{
36593673
title: 'parses tuic v5 lines',
36603674
input: `Surge TUIC = tuic-v5,surge-tuic.example.com,443,uuid=${UUID},password=secret,sni=sni.example.com,skip-cert-verify=true,alpn=h3,ecn=true,port-hopping=9000;9002-9004`,

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,17 @@ describe('Proxy text producers', function () {
914914
port: 443,
915915
psk: 'secret',
916916
version: 6,
917+
mode: 'unsafe-raw',
918+
udp: true,
919+
},
920+
{
921+
type: 'snell',
922+
name: 'Surge Snell v5 Mode',
923+
server: 'snell.example.com',
924+
port: 443,
925+
psk: 'secret',
926+
version: 5,
927+
mode: 'unshaped',
917928
udp: true,
918929
},
919930
{
@@ -937,7 +948,10 @@ describe('Proxy text producers', function () {
937948
);
938949

939950
expect(output).to.equal(
940-
'Surge Snell v6=snell,snell.example.com,443,version=6,psk="secret",udp-relay=true',
951+
[
952+
'Surge Snell v6=snell,snell.example.com,443,version=6,psk="secret",mode=unsafe-raw,udp-relay=true',
953+
'Surge Snell v5 Mode=snell,snell.example.com,443,version=5,psk="secret",udp-relay=true',
954+
].join('\n'),
941955
);
942956
expect(errors).to.deep.equal([
943957
'Platform Surge does not support Snell version 6 with obfs',

0 commit comments

Comments
 (0)