Skip to content

Commit 6d9907c

Browse files
authored
Merge pull request #814 from cmliu/beta2.0
Beta2.0
2 parents 72789e8 + 6e29fac commit 6d9907c

1 file changed

Lines changed: 19 additions & 19 deletions

File tree

_worker.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -302,31 +302,31 @@ export default {
302302
}
303303
return new Response('无效的订阅TOKEN', { status: 403 });
304304
}
305-
306-
let 伪装页URL = env.URL || 'nginx';
307-
if (伪装页URL && 伪装页URL !== 'nginx' && 伪装页URL !== '1101') {
308-
伪装页URL = 伪装页URL.trim().replace(/\/$/, '');
309-
if (!伪装页URL.match(/^https?:\/\//i)) 伪装页URL = 'https://' + 伪装页URL;
310-
if (伪装页URL.toLowerCase().startsWith('http://')) 伪装页URL = 'https://' + 伪装页URL.substring(7);
311-
try { const u = new URL(伪装页URL); 伪装页URL = u.protocol + '//' + u.host; } catch (e) { 伪装页URL = 'nginx'; }
312-
}
313-
if (伪装页URL === '1101') return new Response(await html1101(url.host, 访问IP), { status: 200, headers: { 'Content-Type': 'text/html; charset=UTF-8' } });
314-
try {
315-
const 反代URL = new URL(伪装页URL), 新请求头 = new Headers(request.headers);
316-
新请求头.set('Host', 反代URL.host);
317-
if (新请求头.has('Referer')) { const u = new URL(新请求头.get('Referer')); 新请求头.set('Referer', 反代URL.protocol + '//' + 反代URL.host + u.pathname + u.search); }
318-
if (新请求头.has('Origin')) 新请求头.set('Origin', 反代URL.protocol + '//' + 反代URL.host);
319-
if (!新请求头.has('User-Agent') && UA && UA !== 'null') 新请求头.set('User-Agent', UA);
320-
return fetch(new Request(反代URL.protocol + 反代URL.host + url.pathname + url.search, { method: request.method, headers: 新请求头, body: request.body, cf: request.cf }));
321-
} catch (error) { }
322-
return new Response(await nginx(), { status: 200, headers: { 'Content-Type': 'text/html; charset=UTF-8' } });
323305
} else if (管理员密码) {// ws代理
324306
await 反代参数获取(request);
325307
const { 0: client, 1: server } = new WebSocketPair();
326308
server.accept();
327309
handleConnection(server, request, userID);
328310
return new Response(null, { status: 101, webSocket: client });
329311
}
312+
313+
let 伪装页URL = env.URL || 'nginx';
314+
if (伪装页URL && 伪装页URL !== 'nginx' && 伪装页URL !== '1101') {
315+
伪装页URL = 伪装页URL.trim().replace(/\/$/, '');
316+
if (!伪装页URL.match(/^https?:\/\//i)) 伪装页URL = 'https://' + 伪装页URL;
317+
if (伪装页URL.toLowerCase().startsWith('http://')) 伪装页URL = 'https://' + 伪装页URL.substring(7);
318+
try { const u = new URL(伪装页URL); 伪装页URL = u.protocol + '//' + u.host; } catch (e) { 伪装页URL = 'nginx'; }
319+
}
320+
if (伪装页URL === '1101') return new Response(await html1101(url.host, 访问IP), { status: 200, headers: { 'Content-Type': 'text/html; charset=UTF-8' } });
321+
try {
322+
const 反代URL = new URL(伪装页URL), 新请求头 = new Headers(request.headers);
323+
新请求头.set('Host', 反代URL.host);
324+
if (新请求头.has('Referer')) { const u = new URL(新请求头.get('Referer')); 新请求头.set('Referer', 反代URL.protocol + '//' + 反代URL.host + u.pathname + u.search); }
325+
if (新请求头.has('Origin')) 新请求头.set('Origin', 反代URL.protocol + '//' + 反代URL.host);
326+
if (!新请求头.has('User-Agent') && UA && UA !== 'null') 新请求头.set('User-Agent', UA);
327+
return fetch(new Request(反代URL.protocol + 反代URL.host + url.pathname + url.search, { method: request.method, headers: 新请求头, body: request.body, cf: request.cf }));
328+
} catch (error) { }
329+
return new Response(await nginx(), { status: 200, headers: { 'Content-Type': 'text/html; charset=UTF-8' } });
330330
}
331331
};
332332
///////////////////////////////////////////////////////////////////////WS传输数据///////////////////////////////////////////////
@@ -375,7 +375,7 @@ function handleConnection(ws, request, FIXED_UUID) {
375375
let isConnecting = false, isReading = false;
376376
let score = 1.0, lastCheck = Date.now(), lastRxBytes = 0, successCount = 0, failCount = 0;
377377
let stats = { total: 0, count: 0, bigChunks: 0, window: 0, timestamp: Date.now() };
378-
let mode = 'direct', avgSize = 0, throughputs = [];
378+
let mode = 'adaptive', avgSize = 0, throughputs = [];
379379

380380
// 动态调整传输模式
381381
const updateMode = size => {

0 commit comments

Comments
 (0)