Skip to content

Commit 30b9113

Browse files
committed
feat: sing-box 非官方版 支持 Snell version 6 quic_proxy_mode 字段(通过节点字段 quic-proxy-mode 设置)
1 parent 48d8321 commit 30b9113

4 files changed

Lines changed: 14 additions & 6 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.22",
3+
"version": "2.36.23",
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/producers/sing-box.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,8 @@ const snellParser = (proxy = {}, includeUnsupportedProxy = false) => {
749749
if (proxy._userkey) parsedProxy.userkey = proxy._userkey;
750750
if (outputVersion === 6) {
751751
if (proxy.mode) parsedProxy.mode = proxy.mode;
752+
if (includeUnsupportedProxy && proxy['quic-proxy-mode'])
753+
parsedProxy.quic_proxy_mode = !!proxy['quic-proxy-mode'];
752754
} else {
753755
if (
754756
proxy['obfs-opts']?.mode &&

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@ describe('Proxy structured producers', function () {
416416
psk: 'secret',
417417
version,
418418
mode: 'unshaped',
419+
'quic-proxy-mode': true,
419420
udp: true,
420421
reuse: true,
421422
'obfs-opts': {
@@ -431,6 +432,7 @@ describe('Proxy structured producers', function () {
431432
expect(result.map((proxy) => proxy.version)).to.deep.equal([4, 4, 6]);
432433
expect(result[1].tag).to.equal('sing-box Snell 5');
433434
expect(result[2].mode).to.equal('unshaped');
435+
expect(result[2]).to.not.have.property('quic_proxy_mode');
434436
expect(result[2]).to.not.have.property('obfs_mode');
435437
expect(errors).to.have.length(2);
436438
expect(errors[0]).to.include(
@@ -450,6 +452,7 @@ describe('Proxy structured producers', function () {
450452
psk: 'secret',
451453
version,
452454
_userkey: `user-${version}`,
455+
'quic-proxy-mode': version === 6 ? false : true,
453456
udp: true,
454457
reuse: true,
455458
}));
@@ -475,6 +478,12 @@ describe('Proxy structured producers', function () {
475478
expect(result.find((proxy) => proxy.version === 5).userkey).to.equal(
476479
'user-5',
477480
);
481+
expect(
482+
result.find((proxy) => proxy.version === 5),
483+
).to.not.have.property('quic_proxy_mode');
484+
expect(
485+
result.find((proxy) => proxy.version === 6).quic_proxy_mode,
486+
).to.equal(undefined);
478487
expect(errors).to.have.length(1);
479488
expect(errors[0]).to.include(
480489
'Platform sing-box does not support snell version 4x',
@@ -1102,10 +1111,7 @@ describe('Proxy structured producers', function () {
11021111

11031112
expect(output.outbounds).to.have.length(6);
11041113
expect(output.outbounds.map((item) => item.tag)).to.deep.equal(
1105-
proxies.flatMap((proxy) => [
1106-
proxy.name,
1107-
`${proxy.name}_shadowtls`,
1108-
]),
1114+
proxies.flatMap((proxy) => [proxy.name, `${proxy.name}_shadowtls`]),
11091115
);
11101116
for (const proxy of proxies) {
11111117
const outbound = output.outbounds.find(

scripts/demo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function operator(proxies = [], targetPlatform, context) {
5555
// 30. Loon 支持使用 `_loon_tls_profile` 设置 `tls-profile` 字段('default', 'chrome', 'ios18', 'ios26'), 否则则使用 client-fingerprint 自动转换部分对应的值
5656
// 31. `shadow-tls-password`/`shadow-tls-sni`/`shadow-tls-version` 这套旧字段已废弃. 请使用 `plugin: 'shadow-tls'` 和 `plugin-opts: { password, host, version }`
5757
// 32. mihomo 中 Snell shadow-tls 字段与 ss shadow-tls 字段不同, 使用的是 obfs-opts 而不是 plugin+plugin-opts, 不能与 obfs http/tls 共存. Sub-Store 内部有字段转换, 建议直接使用单行 Surge 格式 `1=snell,a.com,443,version=4,psk="1",obfs=http,obfs-host=a.com,shadow-tls-password="1",shadow-tls-sni=a.com,shadow-tls-version=3,alpn="http/1.1,h2",reuse=true` . 若想使用 JSON/JSON5/YAML 单行格式输入, 可使用 `{ "name": "1", "server": "a.com", "port": 443, "psk": "1", "version": 4, "reuse": true, "type": "snell", "obfs-opts": { "mode": "http", "host": "a.com" }, "plugin": "shadow-tls", "plugin-opts": { "host": "a.com", "password": "1", "version": 3, "alpn": [ "http/1.1", "h2" ] } }`
58-
// 33. sing-box Snell 出站默认允许 version 4/5/6, 其中 version 5 会按 sing-box 行为输出成 version 4. 开启“含不支持的协议”时保留 version 1/2/3/4/5/6. 节点上的 `_userkey` 会输出为 sing-box 的 `userkey`
58+
// 33. sing-box Snell 出站默认允许 version 4/5/6, 其中 version 5 会按 sing-box 行为输出成 version 4. 开启“含不支持的协议”时保留 version 1/2/3/4/5/6, 并支持 version 6 通过节点字段 `quic-proxy-mode` 设置 `quic_proxy_mode`. 节点上的 `_userkey` 会输出为 sing-box 的 `userkey`
5959
// 34. VLESS/Trojan URI 的 `vcn` 对应 mihomo 的 `name-cert-verify`. Xray-core 支持用逗号分隔多个 name, mihomo 只支持一个, 因此输入时取第一个有效值, 同时用 `_vcn` 数组保留全部有效值; 输出 URI 时优先用 `_vcn` 还原为 `vcn`, 没有 `_vcn` 时才使用 `name-cert-verify`. 若想设置为其他值, 可使用脚本操作设置, 例如 `$server["name-cert-verify"] = $server._vcn?.[1] || $server._vcn?.[0]`
6060

6161
// require 为 Node.js 的 require, 在 Node.js 运行环境下 可以用来引入模块

0 commit comments

Comments
 (0)