UUID可输入任意值,非UUIDv4标准的值会自动切换成动态UUID;

添加变量CSVREMARK,用于指定ADDCSV备注所在列的偏移量;
This commit is contained in:
cmliu
2024-12-07 23:26:47 +08:00
parent 6a29a9c0b4
commit 405ef328eb
2 changed files with 49 additions and 43 deletions

View File

@@ -136,7 +136,7 @@ Telegram交流群[@CMLiussss](https://t.me/CMLiussss)**感谢[Alice Networ
| 变量名 | 示例 | 必填 | 备注 | YT |
|--------|---------|-|-----|-----|
| UUID | `90cd4a77-141a-43c9-991b-08263cfe9c10` |✅| Powershell -NoExit -Command "[guid]::NewGuid()"| [Video](https://www.youtube.com/watch?v=s91zjpw3-P8&t=72s) |
| UUID | `90cd4a77-141a-43c9-991b-08263cfe9c10` |✅| 可输入任意值(非UUIDv4标准的值会自动切换成动态UUID) | [Video](https://www.youtube.com/watch?v=s91zjpw3-P8&t=72s) |
| KEY | `token` |❌| 动态UUID秘钥使用变量`KEY`的时候,将不再启用变量`UUID`| |
| TIME | `7` |❌| 动态UUID有效时间(默认值:`7`天)| |
| UPTIME | `3` |❌| 动态UUID更新时间(默认值:北京时间`3`点更新) | |
@@ -149,6 +149,7 @@ Telegram交流群[@CMLiussss](https://t.me/CMLiussss)**感谢[Alice Networ
| ADDNOTLSAPI | [https://raw.github.../addressesapi.txt](https://raw.githubusercontent.com/cmliu/CFcdnVmess2sub/main/addressesapi.txt) |❌| 优选IP的API地址(支持多元素之间`,`或 换行 作间隔) ||
| ADDCSV | [https://raw.github.../addressescsv.csv](https://raw.githubusercontent.com/cmliu/WorkerVless2sub/main/addressescsv.csv) |❌| iptest测速结果(支持多元素, 元素之间使用`,`作间隔) ||
| DLS | `8` |❌| `ADDCSV`测速结果满足速度下限 ||
| CSVREMARK | `1` |❌| CSV备注所在列偏移量 ||
| TGTOKEN | `6894123456:XXXXXXXXXX0qExVsBPUhHDAbXXX` |❌| 发送TG通知的机器人token |
| TGID | `6946912345` |❌| 接收TG通知的账户数字ID |
| SUB | `VLESS.fxxk.dedyn.io` | ❌ | 优选订阅生成器域名 | [Video](https://www.youtube.com/watch?v=s91zjpw3-P8&t=1193s) |

View File

@@ -44,23 +44,21 @@ let userIDLow;
let userIDTime = "";
let proxyIPPool = [];
let path = '/?ed=2560';
let 动态UUID;
export default {
async fetch(request, env, ctx) {
try {
const UA = request.headers.get('User-Agent') || 'null';
const userAgent = UA.toLowerCase();
if (env.KEY) {
有效时间 = env.TIME || 有效时间;
更新时间 = env.UPTIME || 更新时间;
const userIDs = await 生成动态UUID(env.KEY);
userID = env.UUID || env.uuid || env.PASSWORD || env.pswd || userID;
if (env.KEY || env.TOKEN || (userID && !isValidUUID(userID))) {
动态UUID = env.KEY || env.TOKEN || userID;
有效时间 = Number(env.TIME) || 有效时间;
更新时间 = Number(env.UPTIME) || 更新时间;
const userIDs = await 生成动态UUID(动态UUID);
userID = userIDs[0];
} else if (env.UUID) {
userID = env.UUID;
userIDLow = userIDs[1];
}
subEmoji = env.SUBEMOJI || env.EMOJI || subEmoji;
if(subEmoji == '0') subEmoji = 'false';
if (!userID) {
return new Response('请设置你的UUID变量或尝试重试部署检查变量是否生效', {
@@ -84,7 +82,7 @@ export default {
fakeHostName = `${fakeUserIDMD5.slice(6, 9)}.${fakeUserIDMD5.slice(13, 19)}`;
proxyIP = env.PROXYIP || proxyIP;
proxyIP = env.PROXYIP || env.proxyip || proxyIP;
proxyIPs = await 整理(proxyIP);
proxyIP = proxyIPs[Math.floor(Math.random() * proxyIPs.length)];
@@ -92,16 +90,9 @@ export default {
socks5s = await 整理(socks5Address);
socks5Address = socks5s[Math.floor(Math.random() * socks5s.length)];
socks5Address = socks5Address.split('//')[1] || socks5Address;
if (env.GO2SOCKS5) go2Socks5s = await 整理(env.GO2SOCKS5);
if (env.CFPORTS) httpsPorts = await 整理(env.CFPORTS);
sub = env.SUB || sub;
subConverter = env.SUBAPI || subConverter;
if( subConverter.includes("http://") ){
subConverter = subConverter.split("//")[1];
subProtocol = 'http';
} else {
subConverter = subConverter.split("//")[1] || subConverter;
}
subConfig = env.SUBCONFIG || subConfig;
if (socks5Address) {
try {
parsedSocks5Address = socks5AddressParser(socks5Address);
@@ -116,22 +107,35 @@ export default {
} else {
RproxyIP = env.RPROXYIP || !proxyIP ? 'true' : 'false';
}
if (env.ADD) addresses = await 整理(env.ADD);
if (env.ADDAPI) addressesapi = await 整理(env.ADDAPI);
if (env.ADDNOTLS) addressesnotls = await 整理(env.ADDNOTLS);
if (env.ADDNOTLSAPI) addressesnotlsapi = await 整理(env.ADDNOTLSAPI);
if (env.ADDCSV) addressescsv = await 整理(env.ADDCSV);
DLS = env.DLS || DLS;
remarkIndex = env.CSVREMARK || remarkIndex;
BotToken = env.TGTOKEN || BotToken;
ChatID = env.TGID || ChatID;
if(env.GO2SOCKS5) go2Socks5s = await 整理(env.GO2SOCKS5);
const upgradeHeader = request.headers.get('Upgrade');
const url = new URL(request.url);
if (url.searchParams.has('sub') && url.searchParams.get('sub') !== '') sub = url.searchParams.get('sub');
FileName = env.SUBNAME || FileName;
if (url.searchParams.has('notls')) noTLS = 'true';
if (!upgradeHeader || upgradeHeader !== 'websocket') {
if (env.ADD) addresses = await 整理(env.ADD);
if (env.ADDAPI) addressesapi = await 整理(env.ADDAPI);
if (env.ADDNOTLS) addressesnotls = await 整理(env.ADDNOTLS);
if (env.ADDNOTLSAPI) addressesnotlsapi = await 整理(env.ADDNOTLSAPI);
if (env.ADDCSV) addressescsv = await 整理(env.ADDCSV);
DLS = Number(env.DLS) || DLS;
remarkIndex = Number(env.CSVREMARK) || remarkIndex;
BotToken = env.TGTOKEN || BotToken;
ChatID = env.TGID || ChatID;
FileName = env.SUBNAME || FileName;
subEmoji = env.SUBEMOJI || env.EMOJI || subEmoji;
if (subEmoji == '0') subEmoji = 'false';
sub = env.SUB || sub;
subConverter = env.SUBAPI || subConverter;
if (subConverter.includes("http://") ){
subConverter = subConverter.split("//")[1];
subProtocol = 'http';
} else {
subConverter = subConverter.split("//")[1] || subConverter;
}
subConfig = env.SUBCONFIG || subConfig;
if (url.searchParams.has('sub') && url.searchParams.get('sub') !== '') sub = url.searchParams.get('sub');
if (url.searchParams.has('notls')) noTLS = 'true';
if (url.searchParams.has('proxyip')) {
path = `/?ed=2560&proxyip=${url.searchParams.get('proxyip')}`;
RproxyIP = 'false';
@@ -142,6 +146,7 @@ export default {
path = `/?ed=2560&socks5=${url.searchParams.get('socks')}`;
RproxyIP = 'false';
}
const 路径 = url.pathname.toLowerCase();
if (路径 == '/') {
if (env.URL302) return Response.redirect(env.URL302, 302);
@@ -155,7 +160,7 @@ export default {
} else if (路径 == `/${fakeUserID}`) {
const fakeConfig = await 生成配置信息(userID, request.headers.get('Host'), sub, 'CF-Workers-SUB', RproxyIP, url, env);
return new Response(`${fakeConfig}`, { status: 200 });
} else if (路径 == `/${env.KEY}` || 路径 == `/${userID}`) {
} else if (路径 == `/${动态UUID}` || 路径 == `/${userID}`) {
await sendMessage(`#获取订阅 ${FileName}`, request.headers.get('CF-Connecting-IP'), `UA: ${UA}</tg-spoiler>\n域名: ${url.hostname}\n<tg-spoiler>入口: ${url.pathname + url.search}</tg-spoiler>`);
const 维列斯Config = await 生成配置信息(userID, request.headers.get('Host'), sub, UA, RproxyIP, url, env);
const now = Date.now();
@@ -401,7 +406,7 @@ async function handleTCPOutBound(remoteSocket, addressType, addressRemote, portR
}
let useSocks = false;
if( go2Socks5s.length > 0 && enableSocks ) useSocks = await useSocks5Pattern(addressRemote);
if (go2Socks5s.length > 0 && enableSocks ) useSocks = await useSocks5Pattern(addressRemote);
// 首次尝试连接远程服务器
let tcpSocket = await connectAndWrite(addressRemote, portRemote, useSocks);
@@ -1263,7 +1268,7 @@ async function 生成配置信息(userID, hostName, sub, UA, RproxyIP, _url, env
addresses = addresses.concat(cfips.map(cidr => generateRandomIPFromCIDR(cidr) + '#CF随机节点'));
}
}
const uuid = (_url.pathname == `/${env.KEY}`) ? env.KEY : userID;
const uuid = (_url.pathname == `/${动态UUID}`) ? 动态UUID : userID;
const userAgent = UA.toLowerCase();
const Config = 配置信息(userID , hostName);
const v2ray = Config[0];
@@ -1292,7 +1297,7 @@ async function 生成配置信息(userID, hostName, sub, UA, RproxyIP, _url, env
if (proxyhosts.length != 0) proxyhost = proxyhosts[Math.floor(Math.random() * proxyhosts.length)] + "/";
}
if ( userAgent.includes('mozilla') && !subParams.some(_searchParams => _url.searchParams.has(_searchParams))) {
if (userAgent.includes('mozilla') && !subParams.some(_searchParams => _url.searchParams.has(_searchParams))) {
const newSocks5s = socks5s.map(socks5Address => {
if (socks5Address.includes('@')) return socks5Address.split('@')[1];
else if (socks5Address.includes('//')) return socks5Address.split('//')[1];
@@ -1300,7 +1305,7 @@ async function 生成配置信息(userID, hostName, sub, UA, RproxyIP, _url, env
});
let socks5List = '';
if( go2Socks5s.length > 0 && enableSocks ) {
if (go2Socks5s.length > 0 && enableSocks ) {
socks5List = `${decodeURIComponent('SOCKS5%EF%BC%88%E7%99%BD%E5%90%8D%E5%8D%95%EF%BC%89%3A%20')}`;
if (go2Socks5s.includes(atob('YWxsIGlu'))||go2Socks5s.includes(atob('Kg=='))) socks5List += `${decodeURIComponent('%E6%89%80%E6%9C%89%E6%B5%81%E9%87%8F')}\n`;
else socks5List += `\n ${go2Socks5s.join('\n ')}\n`;
@@ -1325,9 +1330,9 @@ async function 生成配置信息(userID, hostName, sub, UA, RproxyIP, _url, env
if (addressescsv.length > 0) 订阅器 += `ADDCSVIPTest测速csv文件 限速 ${DLS} : \n ${addressescsv.join('\n ')}\n`;
}
if (env.KEY && _url.pathname !== `/${env.KEY}`) 订阅器 = '';
if (动态UUID && _url.pathname !== `/${动态UUID}`) 订阅器 = '';
else 订阅器 += `\nSUBAPI订阅转换后端: ${subProtocol}://${subConverter}\nSUBCONFIG订阅转换配置文件: ${subConfig}`;
const 动态UUID = (uuid != userID) ? `TOKEN: ${uuid}\nUUIDNow: ${userID}\nUUIDLow: ${userIDLow}\n${userIDTime}TIME动态UUID有效时间: ${有效时间}\nUPTIME动态UUID更新时间: ${更新时间} 时(北京时间)\n\n` : `${userIDTime}`;
const 动态UUID信息 = (uuid != userID) ? `TOKEN: ${uuid}\nUUIDNow: ${userID}\nUUIDLow: ${userIDLow}\n${userIDTime}TIME动态UUID有效时间: ${有效时间}\nUPTIME动态UUID更新时间: ${更新时间} 时(北京时间)\n\n` : `${userIDTime}`;
return `
################################################################
Subscribe / sub 订阅地址, 支持 Base64、clash-meta、sing-box 订阅格式
@@ -1350,7 +1355,7 @@ https://${proxyhost}${hostName}/${uuid}?singbox
################################################################
${FileName} 配置信息
---------------------------------------------------------------
${动态UUID}HOST: ${hostName}
${动态UUID信息}HOST: ${hostName}
UUID: ${userID}
FKID: ${fakeUserID}
UA: ${UA}
@@ -1802,7 +1807,7 @@ function 生成动态UUID(密钥) {
function 获取当前周数() {
const 现在 = new Date();
const 调整后的现在 = new Date(现在.getTime() + 时区偏移 * 60 * 60 * 1000);
const 时间差 = 调整后的现在 - 起始日期;
const 时间差 = Number(调整后的现在) - Number(起始日期);
return Math.ceil(时间差 / 一周的毫秒数);
}