fix: 修复 sing-box Snell 输出

This commit is contained in:
xream committed 2026-07-01 22:58:49 +08:00
1 parent 387d90c19a
commit cbcefae5ea
4 files changed
+39 -1

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "sub-store",
"version": "2.33.0",
"version": "2.33.1",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
"main": "src/main.js",
"packageManager": "pnpm@11.0.9",
@@ -1280,10 +1280,41 @@ export default function singbox_Producer() {
const type = 'ALL';
const produce = (proxies, type, opts = {}) => {
const list = [];
const originalSnellShadowTLS = new Map(
proxies
.filter(
(proxy) =>
proxy?.type === 'snell' &&
proxy?.plugin === 'shadow-tls' &&
proxy?.['plugin-opts'],
)
.map((proxy) => [
proxy,
{
plugin: proxy.plugin,
'plugin-opts': proxy['plugin-opts']
? JSON.parse(JSON.stringify(proxy['plugin-opts']))
: undefined,
'obfs-opts': proxy['obfs-opts']
? JSON.parse(JSON.stringify(proxy['obfs-opts']))
: undefined,
},
]),
);
ClashMeta_Producer()
.produce(proxies, 'internal', { 'include-unsupported-proxy': true })
.map((proxy) => {
try {
const originalShadowTLS = originalSnellShadowTLS.get(proxy);
if (originalShadowTLS) {
proxy.plugin = originalShadowTLS.plugin;
proxy['plugin-opts'] = originalShadowTLS['plugin-opts'];
if (originalShadowTLS['obfs-opts']) {
proxy['obfs-opts'] = originalShadowTLS['obfs-opts'];
} else {
delete proxy['obfs-opts'];
}
}
if (['xhttp'].includes(proxy.network))
throw new Error(
`Platform sing-box does not support network: ${proxy.network}`,
@@ -487,6 +487,10 @@ describe('Proxy structured producers', function () {
password: 'shadow-pass',
version: 3,
},
'obfs-opts': {
mode: 'http',
host: 'obfs.example.com',
},
},
{ 'include-unsupported-proxy': true },
);
@@ -499,6 +503,8 @@ describe('Proxy structured producers', function () {
version: 4,
reuse: true,
network: 'tcp',
obfs_mode: 'http',
obfs_host: 'obfs.example.com',
detour: 'sing-box Snell ShadowTLS_shadowtls',
});
expect(output.outbounds[0]).to.not.have.property('server');
+1
View File
@@ -54,6 +54,7 @@ function operator(proxies = [], targetPlatform, context) {
// 29. sing-box 支持使用 `ssh-server` 给 tailscale 设置 `ssh_server`, 直接设为 `true` 或 `{ "enabled": true, "disable-pty": true, "disable-sftp": true, "disable-forwarding": true }`
// 30. Loon 支持使用 `_loon_tls_profile` 设置 `tls-profile` 字段('default', 'chrome', 'ios18', 'ios26'), 否则则使用 client-fingerprint 自动转换部分对应的值
// 31. `shadow-tls-password`/`shadow-tls-sni`/`shadow-tls-version` 这套旧字段已废弃. 请使用 `plugin: 'shadow-tls'` 和 `plugin-opts: { password, host, version }`
// 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,h3",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", "h3" ] } }`
// require 为 Node.js 的 require, 在 Node.js 运行环境下 可以用来引入模块
// 例如在 Node.js 环境下, 将文件内容写入 /tmp/1.txt 文件