Skip to content

Commit f3845a4

Browse files
committed
fix: 更新随机路径函数,支持传入完整节点路径并优化路径组合逻辑
1 parent ae3a99c commit f3845a4

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

_worker.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ export default {
300300
return null;
301301
}
302302

303-
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(节点备注)}`;
303+
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(节点备注)}`;
304304
}).filter(item => item !== null).join('\n');
305305
} else { // 订阅转换
306306
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(文本) {
12891289
return 第二次十六进制.toLowerCase();
12901290
}
12911291

1292-
function 随机路径() {
1292+
function 随机路径(完整节点路径 = "/") {
12931293
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"];
12941294
const 随机数 = Math.floor(Math.random() * 3 + 1);
12951295
const 随机路径 = 常用路径目录.sort(() => 0.5 - Math.random()).slice(0, 随机数).join('/');
1296-
return `/${随机路径}`;
1296+
if (完整节点路径 === "/") return `/${随机路径}`;
1297+
else return `/${随机路径 + 完整节点路径.replace('/?', '?')}`;
12971298
}
12981299

12991300
function 随机替换通配符(h) {
@@ -1446,15 +1447,25 @@ async function 读取config_JSON(env, hostname, userID, 重置配置 = false) {
14461447
if (PATH固定参数 === '/') PATH固定参数 = '';
14471448
else while (PATH固定参数.endsWith('/')) PATH固定参数 = PATH固定参数.slice(0, -1);
14481449

1449-
config_JSON.完整节点路径 = config_JSON.启用0RTT ? PATH固定参数 + PATH反代参数 + '?ed=2560' : PATH固定参数 + PATH反代参数;
1450+
// 分离 PATH固定参数 的路径部分和查询参数部分
1451+
let 路径部分 = PATH固定参数, 查询参数部分 = '';
1452+
const 问号位置 = PATH固定参数.indexOf('?');
1453+
if (问号位置 !== -1) {
1454+
路径部分 = PATH固定参数.slice(0, 问号位置);
1455+
查询参数部分 = PATH固定参数.slice(问号位置); // 包含 '?'
1456+
}
1457+
1458+
// 组合路径:路径部分 + 反代参数 + 查询参数 + ed参数
1459+
const 基础路径 = 路径部分 + PATH反代参数 + 查询参数部分;
1460+
config_JSON.完整节点路径 = config_JSON.启用0RTT ? 基础路径 + (查询参数部分 ? '&ed=2560' : '?ed=2560') : 基础路径;
14501461

14511462
if (!config_JSON.TLS分片 && config_JSON.TLS分片 !== null) config_JSON.TLS分片 = null;
14521463
const TLS分片参数 = config_JSON.TLS分片 == 'Shadowrocket' ? `&fragment=${encodeURIComponent('1,40-60,30-50,tlshello')}` : config_JSON.TLS分片 == 'Happ' ? `&fragment=${encodeURIComponent('3,1,tlshello')}` : '';
14531464
if (!config_JSON.Fingerprint) config_JSON.Fingerprint = "chrome";
14541465
if (!config_JSON.ECH) config_JSON.ECH = false;
14551466
if (!config_JSON.ECHConfig) config_JSON.ECHConfig = { DNS: CM_DoH, SNI: null };
14561467
const ECHLINK参数 = config_JSON.ECH ? `&ech=${encodeURIComponent((config_JSON.ECHConfig.SNI ? config_JSON.ECHConfig.SNI + '+' : '') + config_JSON.ECHConfig.DNS)}` : '';
1457-
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)}`;
1468+
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)}`;
14581469
config_JSON.优选订阅生成.TOKEN = await MD5MD5(hostname + userID);
14591470

14601471
const 初始化TG_JSON = { BotToken: null, ChatID: null };

0 commit comments

Comments
 (0)