From 54705cdec5f0edf0a76d72a17df5cc44bc4ca738 Mon Sep 17 00:00:00 2001 From: cmliu Date: Sat, 22 Nov 2025 17:14:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E4=BC=98=E9=80=89?= =?UTF-8?q?=E8=AE=A2=E9=98=85=E7=94=9F=E6=88=90=E5=99=A8URL=E6=9E=84?= =?UTF-8?q?=E5=BB=BA=E9=80=BB=E8=BE=91=EF=BC=8C=E4=BF=AE=E6=AD=A3UUID?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=B9=B6=E6=B7=BB=E5=8A=A0=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E6=9B=BF=E6=8D=A2=E5=9F=9F=E5=90=8D=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _worker.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/_worker.js b/_worker.js index b4ef91a..22f1ec1 100644 --- a/_worker.js +++ b/_worker.js @@ -267,7 +267,7 @@ export default { } else { // 优选订阅生成器 let 优选订阅生成器HOST = url.searchParams.get('sub') || config_JSON.优选订阅生成.SUB; 优选订阅生成器HOST = 优选订阅生成器HOST && !/^https?:\/\//i.test(优选订阅生成器HOST) ? `https://${优选订阅生成器HOST}` : 优选订阅生成器HOST; - const 优选订阅生成器URL = `${优选订阅生成器HOST}/sub?host=example.com&${协议类型 === ('v' + 'le' + 'ss') ? 'uuid' : 'pw'}=00000000-0000-4000-0000-000000000000&path=${encodeURIComponent(config_JSON.随机路径 ? 随机路径() + 节点路径 : 节点路径) + TLS分片参数}&type=${config_JSON.传输协议}`; + const 优选订阅生成器URL = `${优选订阅生成器HOST}/sub?host=example.com&${协议类型 === ('v' + 'le' + 'ss') ? 'uuid' : 'pw'}=00000000-0000-4000-8000-000000000000&path=${encodeURIComponent(config_JSON.随机路径 ? 随机路径() + 节点路径 : 节点路径) + TLS分片参数}&type=${config_JSON.传输协议}`; try { const response = await fetch(优选订阅生成器URL, { headers: { 'User-Agent': 'v2rayN/edge' + 'tunnel (https://github.com/cmliu/edge' + 'tunnel)' } }); if (response.ok) 订阅内容 = btoa(其他节点LINK + atob(await response.text())); @@ -289,9 +289,9 @@ export default { } } if (订阅类型 === 'mixed') { - 订阅内容 = atob(订阅内容).replace(/example.com/g, config_JSON.HOST).replace(/00000000-0000-4000-0000-000000000000/g, config_JSON.UUID); + 订阅内容 = 批量替换域名(atob(订阅内容).replace(/00000000-0000-4000-8000-000000000000/g, config_JSON.UUID), host); if (!ua.includes('mozilla')) 订阅内容 = btoa(订阅内容); - } else 订阅内容 = 订阅内容.replace(/example.com/g, config_JSON.HOST).replace(/00000000-0000-4000-0000-000000000000/g, config_JSON.UUID); + } else 订阅内容 = 批量替换域名(订阅内容.replace(/00000000-0000-4000-8000-000000000000/g, config_JSON.UUID), host); if (订阅类型 === 'singbox') { 订阅内容 = JSON.stringify(JSON.parse(订阅内容), null, 2); responseHeaders["content-type"] = 'application/json; charset=utf-8'; @@ -835,6 +835,15 @@ function 随机替换通配符(h) { }); } +function 批量替换域名(内容, host, 每组数量 = 2) { + let count = 0, currentRandomHost = null; + return 内容.replace(/example\.com/g, () => { + if (count % 每组数量 === 0) currentRandomHost = 随机替换通配符(host); + count++; + return currentRandomHost; + }); +} + async function 读取config_JSON(env, hostname, userID, 重置配置 = false) { const host = 随机替换通配符(hostname); const 初始化开始时间 = performance.now();