From baff8445b5eb883d98e9d794872f7a41708d2748 Mon Sep 17 00:00:00 2001 From: smilence86 Date: Wed, 16 Aug 2023 19:39:59 +0800 Subject: [PATCH 1/2] show qrcode at result page --- src/worker-vless.js | 61 ++++++++++++++++++++++++++++++--------------- 1 file changed, 41 insertions(+), 20 deletions(-) diff --git a/src/worker-vless.js b/src/worker-vless.js index b84c6cbf7..37b2182bb 100644 --- a/src/worker-vless.js +++ b/src/worker-vless.js @@ -4,7 +4,7 @@ import { connect } from 'cloudflare:sockets'; // How to generate your own UUID: // [Windows] Press "Win + R", input cmd and run: Powershell -NoExit -Command "[guid]::NewGuid()" -let userID = 'd342d11e-d424-4583-b36e-524ab1f0afa4'; +let userID = '5081b17b-7bd2-4d34-b1fb-261edd467230'; let proxyIP = ''; @@ -31,11 +31,32 @@ export default { case '/': return new Response(JSON.stringify(request.cf), { status: 200 }); case `/${userID}`: { - const vlessConfig = getVLESSConfig(userID, request.headers.get('Host')); - return new Response(`${vlessConfig}`, { + const [vlessMain, vlessConfig] = getVLESSConfig(userID, request.headers.get('Host')); + const html = ` + + connect info + + + +

scan qrcode to connect.

+ +
+ +
+ + + +
+ +
${vlessConfig}
+ + `; + return new Response(`${html}`, { status: 200, headers: { - "Content-Type": "text/plain;charset=utf-8", + "content-type": "text/html;charset=UTF-8", } }); } @@ -600,8 +621,8 @@ async function handleUDPOutBound(webSocket, vlessResponseHeader, log) { * @returns {string} */ function getVLESSConfig(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 ` + const vlessMain = `vless://${userID}@${hostName}:443?encryption=none&security=tls&sni=${hostName}&fp=randomized&type=ws&host=${hostName}&path=%2F%3Fed%3D2048#${hostName}`; + const result = ` ################################################################ v2ray --------------------------------------------------------------- @@ -611,21 +632,21 @@ ${vlessMain} clash-meta --------------------------------------------------------------- - type: vless - name: ${hostName} - server: ${hostName} - port: 443 - uuid: ${userID} - network: ws - tls: true - udp: false - sni: ${hostName} - client-fingerprint: chrome - ws-opts: - path: "/?ed=2048" - headers: - host: ${hostName} +name: ${hostName} +server: ${hostName} +port: 443 +uuid: ${userID} +network: ws +tls: true +udp: false +sni: ${hostName} +client-fingerprint: chrome +ws-opts: + path: "/?ed=2048" + headers: + host: ${hostName} --------------------------------------------------------------- ################################################################ `; + return [vlessMain, result]; } - From 539af2fd242c3c35bf7f2e4cc784628b099bfb58 Mon Sep 17 00:00:00 2001 From: smilence86 Date: Wed, 16 Aug 2023 19:41:44 +0800 Subject: [PATCH 2/2] restore uuid --- src/worker-vless.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/worker-vless.js b/src/worker-vless.js index 37b2182bb..b0b0aca0c 100644 --- a/src/worker-vless.js +++ b/src/worker-vless.js @@ -4,7 +4,7 @@ import { connect } from 'cloudflare:sockets'; // How to generate your own UUID: // [Windows] Press "Win + R", input cmd and run: Powershell -NoExit -Command "[guid]::NewGuid()" -let userID = '5081b17b-7bd2-4d34-b1fb-261edd467230'; +let userID = 'd342d11e-d424-4583-b36e-524ab1f0afa4'; let proxyIP = '';