Skip to content

Commit

Permalink
add uuid path
Browse files Browse the repository at this point in the history
  • Loading branch information
Emo-Damage committed Jun 4, 2023
1 parent afcb5a4 commit 41da84e
Showing 1 changed file with 48 additions and 2 deletions.
50 changes: 48 additions & 2 deletions src/worker-vless.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,30 @@ export default {
switch (url.pathname) {
case '/':
return new Response(JSON.stringify(request.cf), { status: 200 });
case `/${userID}`:
return new Response(`${userID}`, { status: 200 });
case `/${userID}`: {
const vlessConfig = getV2rayNConfig(userID, request.headers.get('Host'));
return new Response(`${vlessConfig}`, {
status: 200,
headers: {
"Content-Type": "text/plain;charset=utf-8",
}
});
}
case `/${userID}/v2`:
const v2raySub = getV2raySub(userID, request.headers.get('Host'));
return new Response(`${v2raySub}`, {
status: 200,
headers: {
"Content-Type": "text/plain;charset=utf-8",
}
});
case `/${userID}/clash`:
return new Response(`todo`, {
status: 200,
headers: {
"Content-Type": "text/plain;charset=utf-8",
}
});
default:
return new Response('Not found', { status: 404 });
}
Expand Down Expand Up @@ -555,3 +577,27 @@ async function handleDNSQuery(udpChunk, webSocket, vlessResponseHeader, log) {
);
}
}


/**
*
* @param {string} userID
* @param {string | null} hostName
* @returns {string}
*/
function getV2raySub(userID, hostName) {
const vlessMain = getV2rayNConfig(userID, hostName);
return btoa(`${vlessMain}`);
}

/**
*
* @param {string} userID
* @param {string | null} hostName
* @returns {string}
*/
function getV2rayNConfig(userID, hostName) {
const vlessMain = `vless://${userID}@${hostName}:443?encryption=none&security=tls&sni=${hostName}&fp=randomized&type=ws&host=${hostName}&path=%2F%3Fed%3D2048#${hostName}`
return vlessMain;
}

0 comments on commit 41da84e

Please sign in to comment.