Skip to content

Commit

Permalink
Update _worker.js
Browse files Browse the repository at this point in the history
  • Loading branch information
cmliu authored Apr 27, 2024
1 parent fd7c7ce commit 8e1c6e1
Showing 1 changed file with 62 additions and 46 deletions.
108 changes: 62 additions & 46 deletions _worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ export default {
return new Response('Not found', { status: 404 });
}
} else {
if (new RegExp('/proxyip=', 'i').test(url.pathname)) proxyIP = url.pathname.split("=")[1];
else if (new RegExp('/proxyip.', 'i').test(url.pathname)) proxyIP = url.pathname.split("/proxyip.")[1];
proxyIP = url.searchParams.get('proxyip') || proxyIP;
if (new RegExp('/proxyip=', 'i').test(url.pathname)) proxyIP = url.pathname.toLowerCase().split('/proxyip=')[1];
else if (new RegExp('/proxyip.', 'i').test(url.pathname)) proxyIP = `proxyip.${url.pathname.toLowerCase().split("/proxyip.")[1]}`;
else if (!proxyIP || proxyIP == '') proxyIP = 'proxyip.fxxk.dedyn.io';
return await vlessOverWSHandler(request);
}
Expand Down Expand Up @@ -852,51 +853,78 @@ async function ADD(envadd) {
return add ;
}

function 配置信息(UUID, 域名地址) {
const 啥啥啥_写的这是啥啊 = 'dmxlc3M=';
const 协议类型 = atob(啥啥啥_写的这是啥啊);

const 别名 = 域名地址;
let 地址 = 域名地址;
let 端口 = 443;

const 用户ID = UUID;
const 加密方式 = 'none';

const 传输层协议 = 'ws';
const 伪装域名 = 域名地址;
const 路径 = '/?ed=2560';

let 传输层安全 = ['tls',true];
const SNI = 域名地址;
const 指纹 = 'randomized';

if (域名地址.includes('.workers.dev')){
地址 = 'www.wto.org';
端口 = 80 ;
传输层安全 = ['',false];
}

const v2ray = `${协议类型}://${用户ID}@${地址}:${端口}?encryption=${加密方式}&security=${传输层安全[0]}&sni=${SNI}&fp=${指纹}&type=${传输层协议}&host=${伪装域名}&path=${encodeURIComponent(路径)}#${encodeURIComponent(别名)}`;
const clash = `- type: ${协议类型}
name: ${别名}
server: ${地址}
port: ${端口}
uuid: ${用户ID}
network: ${传输层协议}
tls: ${传输层安全[1]}
udp: false
sni: ${SNI}
client-fingerprint: ${指纹}
ws-opts:
path: "${路径}"
headers:
host: ${伪装域名}`;
return [v2ray,clash];
}

/**
* @param {string} userID
* @param {string | null} hostName
* @param {string} sub
* @param {string} userAgent
* @returns {Promise<string>}
*/
let vv = 'v';
let ll = 'l';
let ee = 'e';
let ss = 's';
async function getVLESSConfig(userID, hostName, sub, userAgent, RproxyIP) {
const Config = 配置信息(userID , hostName);
const v2ray = Config[0];
const clash = Config[1];
// 如果sub为空,则显示原始内容
if (!sub || sub === '') {
const cmliuMain = `${vv}${ll}${ee}${ss}${ss}://${userID}@${hostName}:443?encryption=none&security=tls&sni=${hostName}&fp=randomized&type=ws&host=${hostName}&path=%2F%3Fed%3D2560#${hostName}`;


return `
################################################################
v2ray
---------------------------------------------------------------
${cmliuMain}
${v2ray}
---------------------------------------------------------------
################################################################
clash-meta
---------------------------------------------------------------
- type: ${vv}${ll}${ee}${ss}${ss}
name: ${hostName}
server: ${hostName}
port: 443
uuid: ${userID}
network: ws
tls: true
udp: false
sni: ${hostName}
client-fingerprint: chrome
ws-opts:
path: "/?ed=2560"
headers:
host: ${hostName}
${clash}
---------------------------------------------------------------
################################################################
`;
} else if (sub && userAgent.includes('mozilla') && !userAgent.includes('linux x86')) {
const cmliuMain = `${vv}${ll}${ee}${ss}${ss}://${userID}@${hostName}:443?encryption=none&security=tls&sni=${hostName}&fp=randomized&type=ws&host=${hostName}&path=%2F%3Fed%3D2560#${hostName}`;


return `
################################################################
Subscribe / sub 订阅地址, 支持 Base64、clash-meta、sing-box 订阅格式, 您的订阅内容由 ${sub} 提供维护支持, 自动获取ProxyIP: ${RproxyIP}.
Expand All @@ -906,25 +934,12 @@ async function getVLESSConfig(userID, hostName, sub, userAgent, RproxyIP) {
################################################################
v2ray
---------------------------------------------------------------
${cmliuMain}
${v2ray}
---------------------------------------------------------------
################################################################
clash-meta
---------------------------------------------------------------
- type: ${vv}${ll}${ee}${ss}${ss}
name: ${hostName}
server: ${hostName}
port: 443
uuid: ${userID}
network: ws
tls: true
udp: false
sni: ${hostName}
client-fingerprint: chrome
ws-opts:
path: "/?ed=2560"
headers:
host: ${hostName}
${clash}
---------------------------------------------------------------
################################################################
telegram 交流群 技术大佬~在线发牌!
Expand All @@ -949,27 +964,28 @@ async function getVLESSConfig(userID, hostName, sub, userAgent, RproxyIP) {
} else {
fakeHostName = `${fakeHostName}.${generateRandomNumber()}.xyz`
}
let content = "";
let url = "";

let url = `https://${sub}/sub?host=${fakeHostName}&uuid=${fakeUserID}&edgetunnel=cmliu&proxyip=${RproxyIP}`;
let isBase64 = false;
if (userAgent.includes('clash') && !userAgent.includes('nekobox')) {
url = `https://${subconverter}/sub?target=clash&url=https%3A%2F%2F${sub}%2Fsub%3Fhost%3D${fakeHostName}%26uuid%3D${fakeUserID}%26edgetunnel%3Dcmliu%26proxyip%3D${RproxyIP}&insert=false&config=${encodeURIComponent(subconfig)}&emoji=true&list=false&tfo=false&scv=true&fdn=false&sort=false&new_name=true`;
url = `https://${subconverter}/sub?target=clash&url=${encodeURIComponent(url)}&insert=false&config=${encodeURIComponent(subconfig)}&emoji=true&list=false&tfo=false&scv=true&fdn=false&sort=false&new_name=true`;
} else if (userAgent.includes('sing-box') || userAgent.includes('singbox')) {
url = `https://${subconverter}/sub?target=singbox&url=https%3A%2F%2F${sub}%2Fsub%3Fhost%3D${fakeHostName}%26uuid%3D${fakeUserID}%26edgetunnel%3Dcmliu%26proxyip%3D${RproxyIP}&insert=false&config=${encodeURIComponent(subconfig)}&emoji=true&list=false&tfo=false&scv=true&fdn=false&sort=false&new_name=true`;
url = `https://${subconverter}/sub?target=singbox&url=${encodeURIComponent(url)}&insert=false&config=${encodeURIComponent(subconfig)}&emoji=true&list=false&tfo=false&scv=true&fdn=false&sort=false&new_name=true`;
} else {
url = `https://${sub}/sub?host=${fakeHostName}&uuid=${fakeUserID}&edgetunnel=cmliu&proxyip=${RproxyIP}`;
isBase64 = true;
}

try {
const response = await fetch(url ,{
headers: {
'User-Agent': 'CF-Workers-edgetunnel/cmliu'
}});
content = await response.text();
const content = await response.text();
return revertFakeInfo(content, userID, hostName, isBase64);
} catch (error) {
console.error('Error fetching content:', error);
return `Error fetching content: ${error.message}`;
}

}
}

0 comments on commit 8e1c6e1

Please sign in to comment.