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 17, 2024
1 parent 931fafe commit 1932e9f
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions _worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default {
// const url = new URL(request.url);
switch (url.pathname.toLowerCase()) {
case '/':
return new Response(JSON.stringify(request.cf), { status: 200 });
return new Response(JSON.stringify(request.cf, null, 4), { status: 200 });
case `/${userID}`: {
const vlessConfig = await getVLESSConfig(userID, request.headers.get('Host'), sub, userAgent, RproxyIP);
const now = Date.now();
Expand Down Expand Up @@ -859,21 +859,25 @@ async function ADD(envadd) {
* @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) {
// 如果sub为空,则显示原始内容
if (!sub || sub === '') {
const vlessMain = `vless://${userID}@${hostName}:443?encryption=none&security=tls&sni=${hostName}&fp=randomized&type=ws&host=${hostName}&path=%2F%3Fed%3D2048#${hostName}`;
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
---------------------------------------------------------------
${vlessMain}
${cmliuMain}
---------------------------------------------------------------
################################################################
clash-meta
---------------------------------------------------------------
- type: vless
- type: ${vv}${ll}${ee}${ss}${ss}
name: ${hostName}
server: ${hostName}
port: 443
Expand All @@ -884,14 +888,14 @@ async function getVLESSConfig(userID, hostName, sub, userAgent, RproxyIP) {
sni: ${hostName}
client-fingerprint: chrome
ws-opts:
path: "/?ed=2048"
path: "/?ed=2560"
headers:
host: ${hostName}
---------------------------------------------------------------
################################################################
`;
} else if (sub && userAgent.includes('mozilla') && !userAgent.includes('linux x86')) {
const vlessMain = `vless://${userID}@${hostName}:443?encryption=none&security=tls&sni=${hostName}&fp=randomized&type=ws&host=${hostName}&path=%2F%3Fed%3D2048#${hostName}`;
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 `
################################################################
Expand All @@ -902,12 +906,12 @@ async function getVLESSConfig(userID, hostName, sub, userAgent, RproxyIP) {
################################################################
v2ray
---------------------------------------------------------------
${vlessMain}
${cmliuMain}
---------------------------------------------------------------
################################################################
clash-meta
---------------------------------------------------------------
- type: vless
- type: ${vv}${ll}${ee}${ss}${ss}
name: ${hostName}
server: ${hostName}
port: 443
Expand All @@ -918,7 +922,7 @@ async function getVLESSConfig(userID, hostName, sub, userAgent, RproxyIP) {
sni: ${hostName}
client-fingerprint: chrome
ws-opts:
path: "/?ed=2048"
path: "/?ed=2560"
headers:
host: ${hostName}
---------------------------------------------------------------
Expand Down

0 comments on commit 1932e9f

Please sign in to comment.