diff --git a/backend/package.json b/backend/package.json index 5273aea4..974ae318 100644 --- a/backend/package.json +++ b/backend/package.json @@ -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", diff --git a/backend/src/core/proxy-utils/producers/sing-box.js b/backend/src/core/proxy-utils/producers/sing-box.js index 6a5e72cb..fbcfcadd 100644 --- a/backend/src/core/proxy-utils/producers/sing-box.js +++ b/backend/src/core/proxy-utils/producers/sing-box.js @@ -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}`, diff --git a/backend/src/test/proxy-producers/structured.spec.js b/backend/src/test/proxy-producers/structured.spec.js index 040634c0..716e3912 100644 --- a/backend/src/test/proxy-producers/structured.spec.js +++ b/backend/src/test/proxy-producers/structured.spec.js @@ -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'); diff --git a/scripts/demo.js b/scripts/demo.js index a768b2d8..37798a81 100644 --- a/scripts/demo.js +++ b/scripts/demo.js @@ -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 文件