mirror of
https://github.com/lush2020/edgetunnel.git
synced 2026-03-21 08:52:43 +08:00
fix: 添加TLS分片参数支持,优化节点路径生成逻辑以增强兼容性
This commit is contained in:
12
_worker.js
12
_worker.js
@@ -226,7 +226,8 @@ 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 节点路径 = config_JSON.启用0RTT ? (config_JSON.PATH == '' ? '/' : config_JSON.PATH) + '?ed=2560' : (config_JSON.PATH == '' ? '/' : 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')}` : '';
|
||||
const 完整优选列表 = config_JSON.优选订阅生成.本地IP库.随机IP ? (await 生成随机IP(request, config_JSON.优选订阅生成.本地IP库.随机数量, config_JSON.优选订阅生成.本地IP库.指定端口))[0] : await env.KV.get('ADD.txt') ? await 整理成数组(await env.KV.get('ADD.txt')) : (await 生成随机IP(request, config_JSON.优选订阅生成.本地IP库.随机数量, config_JSON.优选订阅生成.本地IP库.指定端口))[0];
|
||||
const 优选API = [], 优选IP = [], 其他节点 = [];
|
||||
for (const 元素 of 完整优选列表) {
|
||||
@@ -259,13 +260,13 @@ export default {
|
||||
return null;
|
||||
}
|
||||
|
||||
return `${协议类型}://${config_JSON.UUID}@${节点地址}:${节点端口}?security=tls&type=${config_JSON.传输协议}&host=${config_JSON.HOST}&sni=${config_JSON.HOST}&path=${encodeURIComponent(随机路径() + 节点路径)}&fragment=${encodeURIComponent('1,40-60,30-50,tlshello')}&encryption=none${config_JSON.跳过证书验证 ? '&allowInsecure=1' : ''}#${encodeURIComponent(节点备注)}`;
|
||||
return `${协议类型}://${config_JSON.UUID}@${节点地址}:${节点端口}?security=tls&type=${config_JSON.传输协议}&host=${config_JSON.HOST}&sni=${config_JSON.HOST}&path=${encodeURIComponent(随机路径() + 节点路径) + TLS分片参数}&encryption=none${config_JSON.跳过证书验证 ? '&allowInsecure=1' : ''}#${encodeURIComponent(节点备注)}`;
|
||||
}).filter(item => item !== null).join('\n');
|
||||
订阅内容 = btoa(其他节点LINK + 订阅内容);
|
||||
} 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(随机路径() + 节点路径)}&type=${config_JSON.传输协议}`;
|
||||
const 优选订阅生成器URL = `${优选订阅生成器HOST}/sub?host=example.com&${协议类型 === ('v' + 'le' + 'ss') ? 'uuid' : 'pw'}=00000000-0000-4000-0000-000000000000&path=${encodeURIComponent(随机路径() + 节点路径) + 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()));
|
||||
@@ -832,6 +833,7 @@ async function 读取config_JSON(env, host, userID, 重置配置 = false) {
|
||||
传输协议: "ws",
|
||||
跳过证书验证: true,
|
||||
启用0RTT: true,
|
||||
TLS分片: null,
|
||||
优选订阅生成: {
|
||||
local: true, // true: 基于本地的优选地址 false: 优选订阅生成器
|
||||
本地IP库: {
|
||||
@@ -893,7 +895,9 @@ async function 读取config_JSON(env, host, userID, 重置配置 = false) {
|
||||
config_JSON.HOST = host;
|
||||
config_JSON.UUID = userID;
|
||||
config_JSON.PATH = config_JSON.反代.SOCKS5.启用 ? ('/' + config_JSON.反代.SOCKS5.启用 + (config_JSON.反代.SOCKS5.全局 ? '://' : '=') + config_JSON.反代.SOCKS5.账号) : (config_JSON.反代.PROXYIP === 'auto' ? '' : `/proxyip=${config_JSON.反代.PROXYIP}`);
|
||||
config_JSON.LINK = `${config_JSON.协议类型}://${userID}@${host}:443?security=tls&type=${config_JSON.传输协议}&host=${host}&sni=${host}&path=${encodeURIComponent(config_JSON.PATH)}&fragment=${encodeURIComponent('1,40-60,30-50,tlshello')}&encryption=none${config_JSON.跳过证书验证 ? '&allowInsecure=1' : ''}#${encodeURIComponent(config_JSON.优选订阅生成.SUBNAME)}`;
|
||||
const TLS分片参数 = config_JSON.TLS分片 == 'Shadowrocket' ? `&fragment=${encodeURIComponent('1,40-60,30-50,tlshello')}` : config_JSON.TLS分片 == 'Happ' ? `&fragment=${encodeURIComponent('3,1,tlshello')}` : '';
|
||||
const 节点路径 = config_JSON.启用0RTT ? (config_JSON.PATH == '' ? '/' : config_JSON.PATH) + '?ed=2560' : (config_JSON.PATH == '' ? '/' : config_JSON.PATH);
|
||||
config_JSON.LINK = `${config_JSON.协议类型}://${userID}@${host}:443?security=tls&type=${config_JSON.传输协议}&host=${host}&sni=${host}&path=${encodeURIComponent(config_JSON.启用0RTT ? 节点路径 + '?ed=2560' : 节点路径) + TLS分片参数}&encryption=none${config_JSON.跳过证书验证 ? '&allowInsecure=1' : ''}#${encodeURIComponent(config_JSON.优选订阅生成.SUBNAME)}`;
|
||||
config_JSON.优选订阅生成.TOKEN = await MD5MD5(host + userID);
|
||||
|
||||
const 初始化TG_JSON = { BotToken: null, ChatID: null };
|
||||
|
||||
Reference in New Issue
Block a user