From e4c92fb2fa58cf5fbb8b28f6e351bb3bfd16d011 Mon Sep 17 00:00:00 2001 From: LittleChest Date: Sat, 26 Jul 2025 15:29:31 +0800 Subject: [PATCH] common: Faster check --- common.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/common.js b/common.js index f2c5abb..a006b3d 100644 --- a/common.js +++ b/common.js @@ -51,10 +51,6 @@ export default async function handler( ) { const requestBody = await request.arrayBuffer(); - const bodyHex = Array.from(new Uint8Array(requestBody)) - .map((b) => b.toString(16).padStart(2, "0")) - .join(""); - // Anti-GFW if ( isIPv4(ip) && @@ -63,11 +59,17 @@ export default async function handler( (headers.get("user-agent") === "Go-http-client/1.1" || headers.get("user-agent") === "Go-http-client/2.0") && (headers.get("accept-encoding") === "gzip, br" || - headers.get("accept-encoding") === "gzip") && - bodyHex.slice(4) === - "01100001000000000000077477697474657203636f6d0000010001" + headers.get("accept-encoding") === "gzip") ) { - return new Response(null, { status: 403 }); + const bodyHex = Array.from(new Uint8Array(requestBody)) + .map((b) => b.toString(16).padStart(2, "0")) + .join(""); + if ( + bodyHex.slice(4) === + "01100001000000000000077477697474657203636f6d0000010001" + ) { + return new Response(null, { status: 403 }); + } } queryData = new Uint8Array(requestBody); }