From d1e37ffae01b338598adb9f6b218676723bc2137 Mon Sep 17 00:00:00 2001 From: cmliu Date: Thu, 13 Nov 2025 16:34:13 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E4=BC=AA=E8=A3=85?= =?UTF-8?q?=E9=A1=B5URL=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E7=A1=AE=E4=BF=9D=E6=AD=A3=E7=A1=AE=E8=A7=A3=E6=9E=90=E5=92=8C?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E5=8F=8D=E4=BB=A3URL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _worker.js | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/_worker.js b/_worker.js index 1909526..b72e1f2 100644 --- a/_worker.js +++ b/_worker.js @@ -302,24 +302,6 @@ export default { } return new Response('无效的订阅TOKEN', { status: 403 }); } - - let 伪装页URL = env.URL || 'nginx'; - if (伪装页URL && 伪装页URL !== 'nginx' && 伪装页URL !== '1101') { - 伪装页URL = 伪装页URL.trim().replace(/\/$/, ''); - if (!伪装页URL.match(/^https?:\/\//i)) 伪装页URL = 'https://' + 伪装页URL; - if (伪装页URL.toLowerCase().startsWith('http://')) 伪装页URL = 'https://' + 伪装页URL.substring(7); - try { const u = new URL(伪装页URL); 伪装页URL = u.protocol + '//' + u.host; } catch (e) { 伪装页URL = 'nginx'; } - } - if (伪装页URL === '1101') return new Response(await html1101(url.host, 访问IP), { status: 200, headers: { 'Content-Type': 'text/html; charset=UTF-8' } }); - try { - const 反代URL = new URL(伪装页URL), 新请求头 = new Headers(request.headers); - 新请求头.set('Host', 反代URL.host); - if (新请求头.has('Referer')) { const u = new URL(新请求头.get('Referer')); 新请求头.set('Referer', 反代URL.protocol + '//' + 反代URL.host + u.pathname + u.search); } - if (新请求头.has('Origin')) 新请求头.set('Origin', 反代URL.protocol + '//' + 反代URL.host); - if (!新请求头.has('User-Agent') && UA && UA !== 'null') 新请求头.set('User-Agent', UA); - return fetch(new Request(反代URL.protocol + 反代URL.host + url.pathname + url.search, { method: request.method, headers: 新请求头, body: request.body, cf: request.cf })); - } catch (error) { } - return new Response(await nginx(), { status: 200, headers: { 'Content-Type': 'text/html; charset=UTF-8' } }); } else if (管理员密码) {// ws代理 await 反代参数获取(request); const { 0: client, 1: server } = new WebSocketPair(); @@ -327,6 +309,24 @@ export default { handleConnection(server, request, userID); return new Response(null, { status: 101, webSocket: client }); } + + let 伪装页URL = env.URL || 'nginx'; + if (伪装页URL && 伪装页URL !== 'nginx' && 伪装页URL !== '1101') { + 伪装页URL = 伪装页URL.trim().replace(/\/$/, ''); + if (!伪装页URL.match(/^https?:\/\//i)) 伪装页URL = 'https://' + 伪装页URL; + if (伪装页URL.toLowerCase().startsWith('http://')) 伪装页URL = 'https://' + 伪装页URL.substring(7); + try { const u = new URL(伪装页URL); 伪装页URL = u.protocol + '//' + u.host; } catch (e) { 伪装页URL = 'nginx'; } + } + if (伪装页URL === '1101') return new Response(await html1101(url.host, 访问IP), { status: 200, headers: { 'Content-Type': 'text/html; charset=UTF-8' } }); + try { + const 反代URL = new URL(伪装页URL), 新请求头 = new Headers(request.headers); + 新请求头.set('Host', 反代URL.host); + if (新请求头.has('Referer')) { const u = new URL(新请求头.get('Referer')); 新请求头.set('Referer', 反代URL.protocol + '//' + 反代URL.host + u.pathname + u.search); } + if (新请求头.has('Origin')) 新请求头.set('Origin', 反代URL.protocol + '//' + 反代URL.host); + if (!新请求头.has('User-Agent') && UA && UA !== 'null') 新请求头.set('User-Agent', UA); + return fetch(new Request(反代URL.protocol + 反代URL.host + url.pathname + url.search, { method: request.method, headers: 新请求头, body: request.body, cf: request.cf })); + } catch (error) { } + return new Response(await nginx(), { status: 200, headers: { 'Content-Type': 'text/html; charset=UTF-8' } }); } }; ///////////////////////////////////////////////////////////////////////WS传输数据///////////////////////////////////////////////