mirror of
https://github.com/lush2020/edgetunnel.git
synced 2026-03-21 17:12:33 +08:00
fix: 优化优选订阅生成器URL构建逻辑,修正UUID格式并添加批量替换域名功能
This commit is contained in:
15
_worker.js
15
_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();
|
||||
|
||||
Reference in New Issue
Block a user