From ae3a99ce3ce18c4bcf70e487834b6fdefeae24ae Mon Sep 17 00:00:00 2001 From: cmliu Date: Tue, 27 Jan 2026 05:37:47 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix:=20=E6=9B=B4=E6=96=B0=E8=AF=BB=E5=8F=96?= =?UTF-8?q?config=5FJSON=E5=87=BD=E6=95=B0=EF=BC=8C=E7=AE=80=E5=8C=96?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E5=B9=B6=E6=B7=BB=E5=8A=A0=E5=AE=8C=E6=95=B4?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E8=B7=AF=E5=BE=84=E7=94=9F=E6=88=90=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 5 ++--- _worker.js | 29 +++++++++++++++++++---------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 610eb89..c985fdd 100644 --- a/README.md +++ b/README.md @@ -119,12 +119,11 @@ | **ADMIN** | ✅ | `123456` | 后台管理面板登录密码 | | **KEY** | ❌ | `CMLiussss` | 快速订阅路径密钥,访问 `/CMLiussss` 即可快速获取节点 | | **UUID** | ❌ | `90cd4a77-141a-43c9-991b-08263cfe9c10` | 强制固定UUID,只支持**UUIDv4**标准格式 | -| **HOST** | ❌ | `edt.pages.dev` | 强制固定伪装域名 | -| **PATH** | ❌ | `/` | 强制固定伪装路径 | +| ~~HOST~~ | ❌ | `edt.pages.dev` | ~~强制固定伪装域名~~可通过面板直接设置 | +| ~~PATH~~ | ❌ | `/` | ~~强制固定伪装路径~~可通过面板直接设置 | | **PROXYIP** | ❌ | `proxyip.cmliussss.net:443` | 全局自定义反代 IP | | **URL** | ❌ | `https://cloudflare-error-page-3th.pages.dev` | 默认主页伪装地址(可填写网页 URL 或 `1101`) | | **GO2SOCKS5** | ❌ | `blog.cmliussss.com`,`*.ip111.cn`,`*google.com` | 强制走 SOCKS5 的名单 (`*` 为全局,域名用逗号分隔) | -| **DOH** | ❌ | `https://doh.cmliussss.com/CMLiussss` | 用于解析ECH的DoH服务器 | --- diff --git a/_worker.js b/_worker.js index 3ad0fbc..df08eac 100644 --- a/_worker.js +++ b/_worker.js @@ -92,11 +92,11 @@ export default { return new Response(JSON.stringify(检测代理响应, null, 2), { status: 200, headers: { 'Content-Type': 'application/json;charset=utf-8' } }); } - config_JSON = await 读取config_JSON(env, host, userID, env.PATH); + config_JSON = await 读取config_JSON(env, host, userID); if (访问路径 === 'admin/init') {// 重置配置为默认值 try { - config_JSON = await 读取config_JSON(env, host, userID, env.PATH, true); + config_JSON = await 读取config_JSON(env, host, userID, true); ctx.waitUntil(请求日志记录(env, request, 访问IP, 'Init_Config', config_JSON)); config_JSON.init = '配置已重置为默认值'; return new Response(JSON.stringify(config_JSON, null, 2), { status: 200, headers: { 'Content-Type': 'application/json;charset=utf-8' } }); @@ -191,7 +191,7 @@ export default { } else if (访问路径 === 'sub') {//处理订阅请求 const 订阅TOKEN = await MD5MD5(host + userID); if (url.searchParams.get('token') === 订阅TOKEN) { - config_JSON = await 读取config_JSON(env, host, userID, env.PATH); + config_JSON = await 读取config_JSON(env, host, userID); ctx.waitUntil(请求日志记录(env, request, 访问IP, 'Get_SUB', config_JSON)); const ua = UA.toLowerCase(); const expire = 4102329600;//2099-12-31 到期时间 @@ -233,7 +233,6 @@ export default { const 协议类型 = (url.searchParams.has('surge') || ua.includes('surge')) ? 'tro' + 'jan' : config_JSON.协议类型; let 订阅内容 = ''; if (订阅类型 === 'mixed') { - const 节点路径 = config_JSON.启用0RTT ? config_JSON.PATH + '?ed=2560' : config_JSON.PATH; const TLS分片参数 = config_JSON.TLS分片 == 'Shadowrocket' ? `&fragment=${encodeURIComponent('1,40-60,30-50,tlshello')}` : config_JSON.TLS分片 == 'Happ' ? `&fragment=${encodeURIComponent('3,1,tlshello')}` : ''; let 完整优选IP = [], 其他节点LINK = ''; @@ -301,7 +300,7 @@ export default { return null; } - return `${协议类型}://00000000-0000-4000-8000-000000000000@${节点地址}:${节点端口}?security=tls&type=${config_JSON.传输协议 + ECHLINK参数}&host=example.com&fp=${config_JSON.Fingerprint}&sni=example.com&path=${encodeURIComponent(config_JSON.随机路径 ? 随机路径() + 节点路径 : 节点路径) + TLS分片参数}&encryption=none${config_JSON.跳过证书验证 ? '&insecure=1&allowInsecure=1' : ''}#${encodeURIComponent(节点备注)}`; + return `${协议类型}://00000000-0000-4000-8000-000000000000@${节点地址}:${节点端口}?security=tls&type=${config_JSON.传输协议 + ECHLINK参数}&host=example.com&fp=${config_JSON.Fingerprint}&sni=example.com&path=${encodeURIComponent(config_JSON.随机路径 ? 随机路径() + config_JSON.完整节点路径 : config_JSON.完整节点路径) + TLS分片参数}&encryption=none${config_JSON.跳过证书验证 ? '&insecure=1&allowInsecure=1' : ''}#${encodeURIComponent(节点备注)}`; }).filter(item => item !== null).join('\n'); } else { // 订阅转换 const 订阅转换URL = `${config_JSON.订阅转换配置.SUBAPI}/sub?target=${订阅类型}&url=${encodeURIComponent(url.protocol + '//' + url.host + '/sub?target=mixed&token=' + 订阅TOKEN + (url.searchParams.has('sub') && url.searchParams.get('sub') != '' ? `&sub=${url.searchParams.get('sub')}` : ''))}&config=${encodeURIComponent(config_JSON.订阅转换配置.SUBCONFIG)}&emoji=${config_JSON.订阅转换配置.SUBEMOJI}&scv=${config_JSON.跳过证书验证}`; @@ -1188,12 +1187,11 @@ function Surge订阅配置文件热补丁(content, url, config_JSON) { const 每行内容 = content.includes('\r\n') ? content.split('\r\n') : content.split('\n'); let 输出内容 = ""; - const realSurgePath = config_JSON.启用0RTT ? config_JSON.PATH + '?ed=2560' : config_JSON.PATH; for (let x of 每行内容) { if (x.includes('= tro' + 'jan,') && !x.includes('ws=true') && !x.includes('ws-path=')) { const host = x.split("sni=")[1].split(",")[0]; const 备改内容 = `sni=${host}, skip-cert-verify=${config_JSON.跳过证书验证}`; - const 正确内容 = `sni=${host}, skip-cert-verify=${config_JSON.跳过证书验证}, ws=true, ws-path=${realSurgePath}, ws-headers=Host:"${host}"`; + const 正确内容 = `sni=${host}, skip-cert-verify=${config_JSON.跳过证书验证}, ws=true, ws-path=${config_JSON.随机路径 ? 随机路径() + config_JSON.完整节点路径 : config_JSON.完整节点路径}, ws-headers=Host:"${host}"`; 输出内容 += x.replace(new RegExp(备改内容, 'g'), 正确内容).replace("[", "").replace("]", "") + '\n'; } else { 输出内容 += x + '\n'; @@ -1351,7 +1349,7 @@ async function getECH(host) { } } -async function 读取config_JSON(env, hostname, userID, path, 重置配置 = false) { +async function 读取config_JSON(env, hostname, userID, 重置配置 = false) { //const host = 随机替换通配符(hostname); const host = hostname, CM_DoH = "https://doh.cmliussss.net/CMLiussss"; const 初始化开始时间 = performance.now(); @@ -1360,6 +1358,7 @@ async function 读取config_JSON(env, hostname, userID, path, 重置配置 = fal HOST: host, HOSTS: [hostname], UUID: userID, + PATH: "/", 协议类型: "v" + "le" + "ss", 传输协议: "ws", 跳过证书验证: true, @@ -1438,14 +1437,24 @@ async function 读取config_JSON(env, hostname, userID, path, 重置配置 = fal config_JSON.UUID = userID; if (!config_JSON.随机路径) config_JSON.随机路径 = false; if (!config_JSON.启用0RTT) config_JSON.启用0RTT = false; - config_JSON.PATH = path ? (path.startsWith('/') ? path : '/' + path) : (config_JSON.反代.SOCKS5.启用 ? ('/' + config_JSON.反代.SOCKS5.启用 + (config_JSON.反代.SOCKS5.全局 ? '://' : '=') + config_JSON.反代.SOCKS5.账号) : (config_JSON.反代.PROXYIP === 'auto' ? '/' : `/proxyip=${config_JSON.反代.PROXYIP}`)); + + if (env.PATH) config_JSON.PATH = env.PATH.startsWith('/') ? env.PATH : '/' + env.PATH; + else if (!config_JSON.PATH) config_JSON.PATH = '/'; + + const PATH反代参数 = config_JSON.反代.SOCKS5.启用 ? ('/' + config_JSON.反代.SOCKS5.启用 + (config_JSON.反代.SOCKS5.全局 ? '://' : '=') + config_JSON.反代.SOCKS5.账号) : (config_JSON.反代.PROXYIP === 'auto' ? '/' : `/proxyip=${config_JSON.反代.PROXYIP}`); + let PATH固定参数 = config_JSON.PATH; + if (PATH固定参数 === '/') PATH固定参数 = ''; + else while (PATH固定参数.endsWith('/')) PATH固定参数 = PATH固定参数.slice(0, -1); + + config_JSON.完整节点路径 = config_JSON.启用0RTT ? PATH固定参数 + PATH反代参数 + '?ed=2560' : PATH固定参数 + PATH反代参数; + if (!config_JSON.TLS分片 && config_JSON.TLS分片 !== null) config_JSON.TLS分片 = null; const TLS分片参数 = config_JSON.TLS分片 == 'Shadowrocket' ? `&fragment=${encodeURIComponent('1,40-60,30-50,tlshello')}` : config_JSON.TLS分片 == 'Happ' ? `&fragment=${encodeURIComponent('3,1,tlshello')}` : ''; if (!config_JSON.Fingerprint) config_JSON.Fingerprint = "chrome"; if (!config_JSON.ECH) config_JSON.ECH = false; if (!config_JSON.ECHConfig) config_JSON.ECHConfig = { DNS: CM_DoH, SNI: null }; const ECHLINK参数 = config_JSON.ECH ? `&ech=${encodeURIComponent((config_JSON.ECHConfig.SNI ? config_JSON.ECHConfig.SNI + '+' : '') + config_JSON.ECHConfig.DNS)}` : ''; - config_JSON.LINK = `${config_JSON.协议类型}://${userID}@${host}:443?security=tls&type=${config_JSON.传输协议 + ECHLINK参数}&host=${host}&fp=${config_JSON.Fingerprint}&sni=${host}&path=${encodeURIComponent(config_JSON.启用0RTT ? config_JSON.PATH + '?ed=2560' : config_JSON.PATH) + TLS分片参数}&encryption=none${config_JSON.跳过证书验证 ? '&insecure=1&allowInsecure=1' : ''}#${encodeURIComponent(config_JSON.优选订阅生成.SUBNAME)}`; + config_JSON.LINK = `${config_JSON.协议类型}://${userID}@${host}:443?security=tls&type=${config_JSON.传输协议 + ECHLINK参数}&host=${host}&fp=${config_JSON.Fingerprint}&sni=${host}&path=${encodeURIComponent(config_JSON.随机路径 ? 随机路径() + config_JSON.完整节点路径 : config_JSON.完整节点路径) + TLS分片参数}&encryption=none${config_JSON.跳过证书验证 ? '&insecure=1&allowInsecure=1' : ''}#${encodeURIComponent(config_JSON.优选订阅生成.SUBNAME)}`; config_JSON.优选订阅生成.TOKEN = await MD5MD5(hostname + userID); const 初始化TG_JSON = { BotToken: null, ChatID: null }; From f3845a41cc81f1c01e2064be671bbdd3a2f5c5fd Mon Sep 17 00:00:00 2001 From: cmliu Date: Tue, 27 Jan 2026 17:37:56 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix:=20=E6=9B=B4=E6=96=B0=E9=9A=8F=E6=9C=BA?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E5=87=BD=E6=95=B0=EF=BC=8C=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E4=BC=A0=E5=85=A5=E5=AE=8C=E6=95=B4=E8=8A=82=E7=82=B9=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E5=B9=B6=E4=BC=98=E5=8C=96=E8=B7=AF=E5=BE=84=E7=BB=84?= =?UTF-8?q?=E5=90=88=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _worker.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/_worker.js b/_worker.js index df08eac..801699c 100644 --- a/_worker.js +++ b/_worker.js @@ -300,7 +300,7 @@ export default { return null; } - return `${协议类型}://00000000-0000-4000-8000-000000000000@${节点地址}:${节点端口}?security=tls&type=${config_JSON.传输协议 + ECHLINK参数}&host=example.com&fp=${config_JSON.Fingerprint}&sni=example.com&path=${encodeURIComponent(config_JSON.随机路径 ? 随机路径() + config_JSON.完整节点路径 : config_JSON.完整节点路径) + TLS分片参数}&encryption=none${config_JSON.跳过证书验证 ? '&insecure=1&allowInsecure=1' : ''}#${encodeURIComponent(节点备注)}`; + return `${协议类型}://00000000-0000-4000-8000-000000000000@${节点地址}:${节点端口}?security=tls&type=${config_JSON.传输协议 + ECHLINK参数}&host=example.com&fp=${config_JSON.Fingerprint}&sni=example.com&path=${encodeURIComponent(config_JSON.随机路径 ? 随机路径(config_JSON.完整节点路径) : config_JSON.完整节点路径) + TLS分片参数}&encryption=none${config_JSON.跳过证书验证 ? '&insecure=1&allowInsecure=1' : ''}#${encodeURIComponent(节点备注)}`; }).filter(item => item !== null).join('\n'); } else { // 订阅转换 const 订阅转换URL = `${config_JSON.订阅转换配置.SUBAPI}/sub?target=${订阅类型}&url=${encodeURIComponent(url.protocol + '//' + url.host + '/sub?target=mixed&token=' + 订阅TOKEN + (url.searchParams.has('sub') && url.searchParams.get('sub') != '' ? `&sub=${url.searchParams.get('sub')}` : ''))}&config=${encodeURIComponent(config_JSON.订阅转换配置.SUBCONFIG)}&emoji=${config_JSON.订阅转换配置.SUBEMOJI}&scv=${config_JSON.跳过证书验证}`; @@ -1289,11 +1289,12 @@ async function MD5MD5(文本) { return 第二次十六进制.toLowerCase(); } -function 随机路径() { +function 随机路径(完整节点路径 = "/") { const 常用路径目录 = ["about", "account", "acg", "act", "activity", "ad", "ads", "ajax", "album", "albums", "anime", "api", "app", "apps", "archive", "archives", "article", "articles", "ask", "auth", "avatar", "bbs", "bd", "blog", "blogs", "book", "books", "bt", "buy", "cart", "category", "categories", "cb", "channel", "channels", "chat", "china", "city", "class", "classify", "clip", "clips", "club", "cn", "code", "collect", "collection", "comic", "comics", "community", "company", "config", "contact", "content", "course", "courses", "cp", "data", "detail", "details", "dh", "directory", "discount", "discuss", "dl", "dload", "doc", "docs", "document", "documents", "doujin", "download", "downloads", "drama", "edu", "en", "ep", "episode", "episodes", "event", "events", "f", "faq", "favorite", "favourites", "favs", "feedback", "file", "files", "film", "films", "forum", "forums", "friend", "friends", "game", "games", "gif", "go", "go.html", "go.php", "group", "groups", "help", "home", "hot", "htm", "html", "image", "images", "img", "index", "info", "intro", "item", "items", "ja", "jp", "jump", "jump.html", "jump.php", "jumping", "knowledge", "lang", "lesson", "lessons", "lib", "library", "link", "links", "list", "live", "lives", "m", "mag", "magnet", "mall", "manhua", "map", "member", "members", "message", "messages", "mobile", "movie", "movies", "music", "my", "new", "news", "note", "novel", "novels", "online", "order", "out", "out.html", "out.php", "outbound", "p", "page", "pages", "pay", "payment", "pdf", "photo", "photos", "pic", "pics", "picture", "pictures", "play", "player", "playlist", "post", "posts", "product", "products", "program", "programs", "project", "qa", "question", "rank", "ranking", "read", "readme", "redirect", "redirect.html", "redirect.php", "reg", "register", "res", "resource", "retrieve", "sale", "search", "season", "seasons", "section", "seller", "series", "service", "services", "setting", "settings", "share", "shop", "show", "shows", "site", "soft", "sort", "source", "special", "star", "stars", "static", "stock", "store", "stream", "streaming", "streams", "student", "study", "tag", "tags", "task", "teacher", "team", "tech", "temp", "test", "thread", "tool", "tools", "topic", "topics", "torrent", "trade", "travel", "tv", "txt", "type", "u", "upload", "uploads", "url", "urls", "user", "users", "v", "version", "video", "videos", "view", "vip", "vod", "watch", "web", "wenku", "wiki", "work", "www", "zh", "zh-cn", "zh-tw", "zip"]; const 随机数 = Math.floor(Math.random() * 3 + 1); const 随机路径 = 常用路径目录.sort(() => 0.5 - Math.random()).slice(0, 随机数).join('/'); - return `/${随机路径}`; + if (完整节点路径 === "/") return `/${随机路径}`; + else return `/${随机路径 + 完整节点路径.replace('/?', '?')}`; } function 随机替换通配符(h) { @@ -1446,7 +1447,17 @@ async function 读取config_JSON(env, hostname, userID, 重置配置 = false) { if (PATH固定参数 === '/') PATH固定参数 = ''; else while (PATH固定参数.endsWith('/')) PATH固定参数 = PATH固定参数.slice(0, -1); - config_JSON.完整节点路径 = config_JSON.启用0RTT ? PATH固定参数 + PATH反代参数 + '?ed=2560' : PATH固定参数 + PATH反代参数; + // 分离 PATH固定参数 的路径部分和查询参数部分 + let 路径部分 = PATH固定参数, 查询参数部分 = ''; + const 问号位置 = PATH固定参数.indexOf('?'); + if (问号位置 !== -1) { + 路径部分 = PATH固定参数.slice(0, 问号位置); + 查询参数部分 = PATH固定参数.slice(问号位置); // 包含 '?' + } + + // 组合路径:路径部分 + 反代参数 + 查询参数 + ed参数 + const 基础路径 = 路径部分 + PATH反代参数 + 查询参数部分; + config_JSON.完整节点路径 = config_JSON.启用0RTT ? 基础路径 + (查询参数部分 ? '&ed=2560' : '?ed=2560') : 基础路径; if (!config_JSON.TLS分片 && config_JSON.TLS分片 !== null) config_JSON.TLS分片 = null; const TLS分片参数 = config_JSON.TLS分片 == 'Shadowrocket' ? `&fragment=${encodeURIComponent('1,40-60,30-50,tlshello')}` : config_JSON.TLS分片 == 'Happ' ? `&fragment=${encodeURIComponent('3,1,tlshello')}` : ''; @@ -1454,7 +1465,7 @@ async function 读取config_JSON(env, hostname, userID, 重置配置 = false) { if (!config_JSON.ECH) config_JSON.ECH = false; if (!config_JSON.ECHConfig) config_JSON.ECHConfig = { DNS: CM_DoH, SNI: null }; const ECHLINK参数 = config_JSON.ECH ? `&ech=${encodeURIComponent((config_JSON.ECHConfig.SNI ? config_JSON.ECHConfig.SNI + '+' : '') + config_JSON.ECHConfig.DNS)}` : ''; - config_JSON.LINK = `${config_JSON.协议类型}://${userID}@${host}:443?security=tls&type=${config_JSON.传输协议 + ECHLINK参数}&host=${host}&fp=${config_JSON.Fingerprint}&sni=${host}&path=${encodeURIComponent(config_JSON.随机路径 ? 随机路径() + config_JSON.完整节点路径 : config_JSON.完整节点路径) + TLS分片参数}&encryption=none${config_JSON.跳过证书验证 ? '&insecure=1&allowInsecure=1' : ''}#${encodeURIComponent(config_JSON.优选订阅生成.SUBNAME)}`; + config_JSON.LINK = `${config_JSON.协议类型}://${userID}@${host}:443?security=tls&type=${config_JSON.传输协议 + ECHLINK参数}&host=${host}&fp=${config_JSON.Fingerprint}&sni=${host}&path=${encodeURIComponent(config_JSON.随机路径 ? 随机路径(config_JSON.完整节点路径) : config_JSON.完整节点路径) + TLS分片参数}&encryption=none${config_JSON.跳过证书验证 ? '&insecure=1&allowInsecure=1' : ''}#${encodeURIComponent(config_JSON.优选订阅生成.SUBNAME)}`; config_JSON.优选订阅生成.TOKEN = await MD5MD5(hostname + userID); const 初始化TG_JSON = { BotToken: null, ChatID: null }; From 5ca1df9df6334f0e1fd2867df035a4e76f72ceb1 Mon Sep 17 00:00:00 2001 From: cmliu Date: Tue, 27 Jan 2026 18:01:00 +0800 Subject: [PATCH 3/4] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E8=AF=BB=E5=8F=96?= =?UTF-8?q?config=5FJSON=E5=87=BD=E6=95=B0=EF=BC=8C=E7=AE=80=E5=8C=96?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E7=BB=84=E5=90=88=E9=80=BB=E8=BE=91=E5=B9=B6?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=AE=8C=E6=95=B4=E8=8A=82=E7=82=B9=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _worker.js | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/_worker.js b/_worker.js index 801699c..9c10afb 100644 --- a/_worker.js +++ b/_worker.js @@ -1442,22 +1442,12 @@ async function 读取config_JSON(env, hostname, userID, 重置配置 = false) { if (env.PATH) config_JSON.PATH = env.PATH.startsWith('/') ? env.PATH : '/' + env.PATH; else if (!config_JSON.PATH) config_JSON.PATH = '/'; - const PATH反代参数 = config_JSON.反代.SOCKS5.启用 ? ('/' + config_JSON.反代.SOCKS5.启用 + (config_JSON.反代.SOCKS5.全局 ? '://' : '=') + config_JSON.反代.SOCKS5.账号) : (config_JSON.反代.PROXYIP === 'auto' ? '/' : `/proxyip=${config_JSON.反代.PROXYIP}`); - let PATH固定参数 = config_JSON.PATH; - if (PATH固定参数 === '/') PATH固定参数 = ''; - else while (PATH固定参数.endsWith('/')) PATH固定参数 = PATH固定参数.slice(0, -1); - - // 分离 PATH固定参数 的路径部分和查询参数部分 - let 路径部分 = PATH固定参数, 查询参数部分 = ''; - const 问号位置 = PATH固定参数.indexOf('?'); - if (问号位置 !== -1) { - 路径部分 = PATH固定参数.slice(0, 问号位置); - 查询参数部分 = PATH固定参数.slice(问号位置); // 包含 '?' - } - - // 组合路径:路径部分 + 反代参数 + 查询参数 + ed参数 - const 基础路径 = 路径部分 + PATH反代参数 + 查询参数部分; - config_JSON.完整节点路径 = config_JSON.启用0RTT ? 基础路径 + (查询参数部分 ? '&ed=2560' : '?ed=2560') : 基础路径; + const { SOCKS5, PROXYIP } = config_JSON.反代; + const PATH反代参数 = SOCKS5.启用 ? `${SOCKS5.启用}${SOCKS5.全局 ? '://' : '='}${SOCKS5.账号}` : (PROXYIP === 'auto' ? '' : `proxyip=${PROXYIP}`); + const normalizedPath = config_JSON.PATH === '/' ? '' : config_JSON.PATH.replace(/\/+(?=\?|$)/, '').replace(/\/+$/, ''); + const [路径部分, ...查询数组] = normalizedPath.split('?'); + const 查询部分 = 查询数组.length ? '?' + 查询数组.join('?') : ''; + config_JSON.完整节点路径 = (路径部分 || '/') + (路径部分 && PATH反代参数 ? '/' : '') + PATH反代参数 + 查询部分 + (config_JSON.启用0RTT ? (查询部分 ? '&' : '?') + 'ed=2560' : ''); if (!config_JSON.TLS分片 && config_JSON.TLS分片 !== null) config_JSON.TLS分片 = null; const TLS分片参数 = config_JSON.TLS分片 == 'Shadowrocket' ? `&fragment=${encodeURIComponent('1,40-60,30-50,tlshello')}` : config_JSON.TLS分片 == 'Happ' ? `&fragment=${encodeURIComponent('3,1,tlshello')}` : ''; From aa68476c6647430c2190b2f0a211023423a5415c Mon Sep 17 00:00:00 2001 From: cmliu Date: Tue, 27 Jan 2026 19:21:21 +0800 Subject: [PATCH 4/4] =?UTF-8?q?fix:=20=E6=9B=B4=E6=96=B0Surge=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=E4=BF=AE=E5=A4=8Dws-path=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E4=BC=A0=E9=80=92=E9=80=BB=E8=BE=91=E4=BB=A5=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=AE=8C=E6=95=B4=E8=8A=82=E7=82=B9=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_worker.js b/_worker.js index 9c10afb..1aa9996 100644 --- a/_worker.js +++ b/_worker.js @@ -1191,7 +1191,7 @@ function Surge订阅配置文件热补丁(content, url, config_JSON) { if (x.includes('= tro' + 'jan,') && !x.includes('ws=true') && !x.includes('ws-path=')) { const host = x.split("sni=")[1].split(",")[0]; const 备改内容 = `sni=${host}, skip-cert-verify=${config_JSON.跳过证书验证}`; - const 正确内容 = `sni=${host}, skip-cert-verify=${config_JSON.跳过证书验证}, ws=true, ws-path=${config_JSON.随机路径 ? 随机路径() + config_JSON.完整节点路径 : config_JSON.完整节点路径}, ws-headers=Host:"${host}"`; + const 正确内容 = `sni=${host}, skip-cert-verify=${config_JSON.跳过证书验证}, ws=true, ws-path=${config_JSON.随机路径 ? 随机路径(config_JSON.完整节点路径) : config_JSON.完整节点路径}, ws-headers=Host:"${host}"`; 输出内容 += x.replace(new RegExp(备改内容, 'g'), 正确内容).replace("[", "").replace("]", "") + '\n'; } else { 输出内容 += x + '\n';