mirror of
https://github.com/sub-store-org/Sub-Store.git
synced 2026-11-27 23:13:43 +00:00
feat: sing-box 非官方版 支持 AnyTLS client_name 字段(通过节点字段 client-name 设置)
This commit is contained in:
4 files changed
+30
-3
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "sub-store",
|
||||
"version": "2.36.23",
|
||||
"version": "2.36.24",
|
||||
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
|
||||
"main": "src/main.js",
|
||||
"packageManager": "pnpm@11.0.9",
|
||||
|
||||
@@ -1117,7 +1117,7 @@ const tuic5Parser = (proxy = {}) => {
|
||||
domainResolverParser(proxy, parsedProxy);
|
||||
return parsedProxy;
|
||||
};
|
||||
const anytlsParser = (proxy = {}) => {
|
||||
const anytlsParser = (proxy = {}, includeUnsupportedProxy = false) => {
|
||||
const parsedProxy = {
|
||||
tag: proxy.name,
|
||||
type: 'anytls',
|
||||
@@ -1126,6 +1126,8 @@ const anytlsParser = (proxy = {}) => {
|
||||
password: proxy.password,
|
||||
tls: { enabled: true, server_name: proxy.server, insecure: false },
|
||||
};
|
||||
if (includeUnsupportedProxy && proxy['client-name'])
|
||||
parsedProxy.client_name = `${proxy['client-name']}`;
|
||||
if (/^\d+$/.test(proxy['idle-session-check-interval']))
|
||||
parsedProxy.idle_session_check_interval = `${proxy['idle-session-check-interval']}s`;
|
||||
if (/^\d+$/.test(proxy['idle-session-timeout']))
|
||||
@@ -1553,7 +1555,12 @@ export default function singbox_Producer() {
|
||||
list.push(wireguardParser(proxy));
|
||||
break;
|
||||
case 'anytls':
|
||||
list.push(anytlsParser(proxy));
|
||||
list.push(
|
||||
anytlsParser(
|
||||
proxy,
|
||||
opts['include-unsupported-proxy'],
|
||||
),
|
||||
);
|
||||
break;
|
||||
case 'tailscale':
|
||||
list.push(tailscaleParser(proxy));
|
||||
|
||||
@@ -1413,6 +1413,25 @@ describe('Proxy structured producers', function () {
|
||||
]);
|
||||
});
|
||||
|
||||
it('emits sing-box AnyTLS client name only when unsupported output is enabled', function () {
|
||||
const proxy = {
|
||||
type: 'anytls',
|
||||
name: 'AnyTLS Client Name',
|
||||
server: 'anytls.example.com',
|
||||
port: 443,
|
||||
password: 'secret',
|
||||
'client-name': 'Sub-Store',
|
||||
};
|
||||
|
||||
const standard = loadProducedJson('sing-box', proxy).outbounds[0];
|
||||
const unsupported = loadProducedJson('sing-box', proxy, {
|
||||
'include-unsupported-proxy': true,
|
||||
}).outbounds[0];
|
||||
|
||||
expect(standard).to.not.have.property('client_name');
|
||||
expect(unsupported.client_name).to.equal('Sub-Store');
|
||||
});
|
||||
|
||||
it('does not emit sing-box ShadowTLS uTLS without client fingerprint', function () {
|
||||
const [proxy] = ProxyUtils.parse(`proxies:
|
||||
- name: SS ShadowTLS No Fingerprint
|
||||
|
||||
@@ -57,6 +57,7 @@ function operator(proxies = [], targetPlatform, context) {
|
||||
// 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" ] } }`
|
||||
// 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`
|
||||
// 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]`
|
||||
// 35. sing-box AnyTLS 开启“含不支持的协议”时, 支持通过节点的字符串字段 `client-name` 设置 `client_name`
|
||||
|
||||
// require 为 Node.js 的 require, 在 Node.js 运行环境下 可以用来引入模块
|
||||
// 例如在 Node.js 环境下, 将文件内容写入 /tmp/1.txt 文件
|
||||
|
||||
Reference in new issue
Block a user