From 8350ac13fcfcaf9c2610b1a7c3c7ef1bc98259c7 Mon Sep 17 00:00:00 2001 From: cmliu Date: Wed, 14 Jan 2026 17:07:18 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=9B=B4=E6=96=B0Singbox=E8=AE=A2?= =?UTF-8?q?=E9=98=85=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E7=83=AD=E8=A1=A5?= =?UTF-8?q?=E4=B8=81=EF=BC=8C=E6=B7=BB=E5=8A=A0UUID=E5=92=8CFingerprint?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E6=94=AF=E6=8C=81=EF=BC=8C=E5=B9=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96TLS=E5=92=8CECH=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _worker.js | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/_worker.js b/_worker.js index cd43cf9..fb0fa49 100644 --- a/_worker.js +++ b/_worker.js @@ -321,7 +321,7 @@ export default { if (订阅类型 === 'mixed' && (!ua.includes('mozilla') || url.searchParams.has('b64') || url.searchParams.has('base64'))) 订阅内容 = btoa(订阅内容); if (订阅类型 === 'singbox') { - 订阅内容 = Singbox订阅配置文件热补丁(订阅内容); + 订阅内容 = Singbox订阅配置文件热补丁(订阅内容, config_JSON.UUID, config_JSON.Fingerprint, config_JSON.ECH ? await getECH(host) : null); responseHeaders["content-type"] = 'application/json; charset=utf-8'; } else if (订阅类型 === 'clash') { responseHeaders["content-type"] = 'application/x-yaml; charset=utf-8'; @@ -784,7 +784,7 @@ async function httpConnect(targetHost, targetPort, initialData) { } } //////////////////////////////////////////////////功能性函数/////////////////////////////////////////////// -function Singbox订阅配置文件热补丁(sb_json_text) { +function Singbox订阅配置文件热补丁(sb_json_text, uuid = null, fingerprint = "chrome", ech_config = null) { try { let config = JSON.parse(sb_json_text); @@ -929,6 +929,35 @@ function Singbox订阅配置文件热补丁(sb_json_text) { } }); + // --- 4. UUID 匹配节点的 TLS 热补丁 (utls & ech) --- + if (uuid) { + config.outbounds.forEach(outbound => { + // 仅处理包含 uuid 且匹配的节点 + if (outbound.uuid && outbound.uuid === uuid) { + // 确保 tls 对象存在 + if (!outbound.tls) { + outbound.tls = { enabled: true }; + } + + // 添加/更新 utls 配置 + if (fingerprint) { + outbound.tls.utls = { + enabled: true, + fingerprint: fingerprint + }; + } + + // 如果提供了 ech_config,添加/更新 ech 配置 + if (ech_config) { + outbound.tls.ech = { + enabled: true, + config: `-----BEGIN ECH CONFIGS-----\n${ech_config}\n-----END ECH CONFIGS-----` + }; + } + } + }); + } + return JSON.stringify(config, null, 2); } catch (e) { console.error("Singbox热补丁执行失败:", e);