Skip to content

Commit da4136e

Browse files
committed
feat: sing-box 支持 AnyTLS client_metadata 字段(通过节点字段 client-metadata 设置)
1 parent 2700c8c commit da4136e

4 files changed

Lines changed: 7 additions & 7 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.28",
3+
"version": "2.36.29",
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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,8 +1126,8 @@ const anytlsParser = (proxy = {}, includeUnsupportedProxy = false) => {
11261126
password: proxy.password,
11271127
tls: { enabled: true, server_name: proxy.server, insecure: false },
11281128
};
1129-
if (includeUnsupportedProxy && proxy['client-name'])
1130-
parsedProxy.client_name = `${proxy['client-name']}`;
1129+
if (proxy['client-metadata'])
1130+
parsedProxy.client_metadata = `${proxy['client-metadata']}`;
11311131
if (/^\d+$/.test(proxy['idle-session-check-interval']))
11321132
parsedProxy.idle_session_check_interval = `${proxy['idle-session-check-interval']}s`;
11331133
if (/^\d+$/.test(proxy['idle-session-timeout']))

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,16 +1420,16 @@ describe('Proxy structured producers', function () {
14201420
server: 'anytls.example.com',
14211421
port: 443,
14221422
password: 'secret',
1423-
'client-name': 'Sub-Store',
1423+
'client-metadata': 'Sub-Store',
14241424
};
14251425

14261426
const standard = loadProducedJson('sing-box', proxy).outbounds[0];
14271427
const unsupported = loadProducedJson('sing-box', proxy, {
14281428
'include-unsupported-proxy': true,
14291429
}).outbounds[0];
14301430

1431-
expect(standard).to.not.have.property('client_name');
1432-
expect(unsupported.client_name).to.equal('Sub-Store');
1431+
expect(standard).to.not.have.property('client_metadata');
1432+
expect(unsupported.client_metadata).to.equal('Sub-Store');
14331433
});
14341434

14351435
it('does not emit sing-box ShadowTLS uTLS without client fingerprint', function () {

scripts/demo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function operator(proxies = [], targetPlatform, context) {
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" ] } }`
5858
// 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]`
60-
// 35. sing-box AnyTLS 开启“含不支持的协议”时, 支持通过节点的字符串字段 `client-name` 设置 `client_name`
60+
// 35. sing-box AnyTLS 支持通过节点的字符串字段 `client-metadata` 设置 `client_metadata`
6161

6262
// require 为 Node.js 的 require, 在 Node.js 运行环境下 可以用来引入模块
6363
// 例如在 Node.js 环境下, 将文件内容写入 /tmp/1.txt 文件

0 commit comments

Comments
 (0)