mirror of
https://github.com/lush2020/edgetunnel.git
synced 2026-03-21 17:12:33 +08:00
change vless to 401 for http
This commit is contained in:
@@ -33,4 +33,11 @@ const index401 = `
|
||||
|
||||
</html>`;
|
||||
|
||||
export { index401 };
|
||||
const page404 = `
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<div class="theme-default-content"><h1>404</h1><blockquote>There's nothing here.</blockquote><a href="/" class="">Take me home</a></div>
|
||||
</html>
|
||||
`;
|
||||
|
||||
export { index401, page404 };
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
vlessJs,
|
||||
} from 'vless-js';
|
||||
import { connect } from 'cloudflare:sockets';
|
||||
import { page404 } from './util';
|
||||
|
||||
interface Env {
|
||||
KV: KVNamespace;
|
||||
@@ -21,8 +22,12 @@ export const onRequest: PagesFunction<Env> = async (context) => {
|
||||
|
||||
const upgradeHeader = context.request.headers.get('Upgrade');
|
||||
if (!upgradeHeader || upgradeHeader !== 'websocket') {
|
||||
return new Response(`Expected Upgrade: websocket`, {
|
||||
status: 404,
|
||||
return new Response(``, {
|
||||
status: 401,
|
||||
headers: {
|
||||
'content-type': 'text/html; charset=utf-8',
|
||||
'WWW-Authenticate': 'Basic',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user