MCPcopy Create free account
hub / github.com/cmliu/WorkerVless2sub / fetch

Function fetch

_worker.js:922–1464  ·  view source on GitHub ↗
(request, env)

Source from the content-addressed store, hash-verified

920
921export default {
922 async fetch(request, env) {
923 if (env.TOKEN) 快速订阅访问入口 = await 整理(env.TOKEN);
924 BotToken = env.TGTOKEN || BotToken;
925 ChatID = env.TGID || ChatID;
926 subConverter = env.SUBAPI || subConverter;
927 if (subConverter.includes("http://")) {
928 subConverter = subConverter.split("//")[1];
929 subProtocol = 'http';
930 } else {
931 subConverter = subConverter.split("//")[1] || subConverter;
932 }
933 subConfig = env.SUBCONFIG || subConfig;
934 FileName = env.SUBNAME || FileName;
935 socks5DataURL = env.SOCKS5DATA || socks5DataURL;
936 if (env.CMPROXYIPS) 匹配PROXYIP = await 整理(env.CMPROXYIPS);;
937 if (env.CFPORTS) httpsPorts = await 整理(env.CFPORTS);
938 EndPS = env.PS || EndPS;
939 网站图标 = env.ICO ? `<link rel="icon" sizes="32x32" href="${env.ICO}">` : '';
940 网站头像 = env.PNG ? `<div class="logo-wrapper"><div class="logo-border"></div><img src="${env.PNG}" alt="Logo"></div>` : '';
941 if (env.IMG) {
942 const imgs = await 整理(env.IMG);
943 网站背景 = `background-image: url('${imgs[Math.floor(Math.random() * imgs.length)]}');`;
944 } else 网站背景 = '';
945 网络备案 = env.BEIAN || env.BY || 网络备案;
946 const userAgentHeader = request.headers.get('User-Agent');
947 const userAgent = userAgentHeader ? userAgentHeader.toLowerCase() : "null";
948 const url = new URL(request.url);
949 const format = url.searchParams.get('format') ? url.searchParams.get('format').toLowerCase() : "null";
950 let host = "";
951 let uuid = "";
952 let path = "";
953 let sni = "";
954 let type = "ws";
955 let scv = env.SCV || 'false';
956 alpn = env.ALPN || alpn;
957 let UD = Math.floor(((timestamp - Date.now()) / timestamp * 99 * 1099511627776) / 2);
958 if (env.UA) MamaJustKilledAMan = MamaJustKilledAMan.concat(await 整理(env.UA));
959
960 const currentDate = new Date();
961 const fakeUserIDMD5 = await MD5MD5(Math.ceil(currentDate.getTime()));
962 fakeUserID = fakeUserIDMD5.slice(0, 8) + "-" + fakeUserIDMD5.slice(8, 12) + "-" + fakeUserIDMD5.slice(12, 16) + "-" + fakeUserIDMD5.slice(16, 20) + "-" + fakeUserIDMD5.slice(20);
963 fakeHostName = fakeUserIDMD5.slice(6, 9) + "." + fakeUserIDMD5.slice(13, 19) + ".xyz";
964
965 total = total * 1099511627776;
966 let expire = Math.floor(timestamp / 1000);
967
968 link = env.LINK || link;
969
970 if (env.ADD) addresses = await 整理(env.ADD);
971 if (env.ADDAPI) addressesapi = await 整理(env.ADDAPI);
972 if (env.ADDNOTLS) addressesnotls = await 整理(env.ADDNOTLS);
973 if (env.ADDNOTLSAPI) addressesnotlsapi = await 整理(env.ADDNOTLSAPI);
974 function moveHttpUrls(sourceArray, targetArray) {
975 if (!Array.isArray(sourceArray) || sourceArray.length === 0) return sourceArray || [];
976 const httpRegex = /^https?:\/\//i;
977 const httpUrls = sourceArray.filter(item => httpRegex.test(item));
978 if (httpUrls.length > 0) {
979 targetArray.push(...httpUrls);

Callers 4

整理优选列表Function · 0.85
整理测速结果Function · 0.85
sendMessageFunction · 0.85
getLinkFunction · 0.85

Calls 15

整理Function · 0.85
MD5MD5Function · 0.85
moveHttpUrlsFunction · 0.85
生成动态UUIDFunction · 0.85
sendMessageFunction · 0.85
nginxFunction · 0.85
subHtmlFunction · 0.85
generateFakeInfoFunction · 0.85
整理优选列表Function · 0.85
整理测速结果Function · 0.85
isValidIPv4Function · 0.85
getRandomProxyByMatchFunction · 0.85

Tested by

no test coverage detected