Skip to content

Commit 22b1abb

Browse files
committed
fix: 更新速度测试站点检查逻辑以支持代理类型条件
1 parent 09a06d4 commit 22b1abb

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- 基于上游传输模型增强 TCP 连接管理:加入 connection generation、socket identity 和旧下行 drain 屏障;重拨期间上行数据继续收纳并等待新 writer,旧 reader、定时器或连接的异步收尾不会污染新连接。[上游思路](https://github.com/ToiCF/GrainTCP/commit/1d22628f4d1413989f521f1d41591b0c72e658eb)
99
- 基于上游 Grain 发送模型统一直发、分段发送、定时 flush 的串行发送链,并持久化异步发送错误;响应头仅在首次真实发送时消费,避免重拨或失效连接提前消耗协议响应头。[上游思路](https://github.com/ToiCF/GrainTCP/commit/1d22628f4d1413989f521f1d41591b0c72e658eb)
1010
- 保持现有多协议兼容性:WS 上行采用非等待入队以降低消息处理阻塞,XHTTP/gRPC 继续等待远端写入完成;本地保留 `16MiB / 4096` 条目的上传高水位保护,避免 Worker 队列无界增长。[上游变更](https://github.com/ToiCF/GrainTCP/commit/1d22628f4d1413989f521f1d41591b0c72e658eb)
11+
- 优化 仅在 **反代模式** 下启用本地测速响应,使用 **SOCKS5/HTTP/HTTPS/TURN/SSTP** 代理时改为正常转发测速请求。
1112

1213
## [2.1.20260722191426] - 2026-07-22 19:14:26
1314

_worker.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ async function 处理XHTTP请求(request, yourUUID, 反代上下文 = {}) {
536536
try { reader.releaseLock() } catch (e) { }
537537
return new Response('Invalid request', { status: 400 });
538538
}
539-
if (isSpeedTestSite(首包.hostname)) {
539+
if (isSpeedTestSite(首包.hostname) && 反代上下文.代理类型 === null) {
540540
try { reader.releaseLock() } catch (e) { }
541541
return new Response(构造本地204响应(首包.respHeader), {
542542
status: 200,
@@ -1093,7 +1093,7 @@ async function 处理gRPC请求(request, yourUUID, 反代上下文 = {}) {
10931093
if (解析结果?.hasError) throw new Error(解析结果.message || 'Invalid trojan request');
10941094
const { port, hostname, rawClientData, isUDP } = 解析结果;
10951095
log(`[gRPC] 木马首包: ${hostname}:${port} | UDP: ${isUDP ? '是' : '否'}`);
1096-
if (isSpeedTestSite(hostname)) {
1096+
if (isSpeedTestSite(hostname) && 反代上下文.代理类型 === null) {
10971097
grpcBridge.send(构造本地204响应());
10981098
return;
10991099
}
@@ -1113,7 +1113,7 @@ async function 处理gRPC请求(request, yourUUID, 反代上下文 = {}) {
11131113
const { port, hostname, version, isUDP, rawClientData } = 解析结果;
11141114
log(`[gRPC] 魏烈思首包: ${hostname}:${port} | UDP: ${isUDP ? '是' : '否'}`);
11151115
const respHeader = new Uint8Array([version, 0]);
1116-
if (isSpeedTestSite(hostname)) {
1116+
if (isSpeedTestSite(hostname) && 反代上下文.代理类型 === null) {
11171117
grpcBridge.send(构造本地204响应(respHeader));
11181118
return;
11191119
}
@@ -1534,7 +1534,7 @@ async function 处理WS请求(request, yourUUID, url, 反代上下文 = {}) {
15341534
const port = (明文数据[cursor] << 8) | 明文数据[cursor + 1];
15351535
cursor += 2;
15361536
const rawClientData = 明文数据.subarray(cursor);
1537-
if (isSpeedTestSite(hostname)) {
1537+
if (isSpeedTestSite(hostname) && 反代上下文.代理类型 === null) {
15381538
await 启用WS本地测速模式(上下文.回包Socket, null, rawClientData);
15391539
return;
15401540
}
@@ -1581,7 +1581,7 @@ async function 处理WS请求(request, yourUUID, url, 反代上下文 = {}) {
15811581
const 解析结果 = 解析木马请求(chunk, yourUUID);
15821582
if (解析结果?.hasError) throw new Error(解析结果.message || 'Invalid trojan request');
15831583
const { port, hostname, rawClientData, isUDP } = 解析结果;
1584-
if (isSpeedTestSite(hostname)) {
1584+
if (isSpeedTestSite(hostname) && 反代上下文.代理类型 === null) {
15851585
await 启用WS本地测速模式(serverSock, null, rawClientData);
15861586
return;
15871587
}
@@ -1602,7 +1602,7 @@ async function 处理WS请求(request, yourUUID, url, 反代上下文 = {}) {
16021602
if (解析结果?.hasError) throw new Error(解析结果.message || 'Invalid 魏烈思 request');
16031603
const { port, hostname, version, isUDP, rawClientData } = 解析结果;
16041604
const respHeader = new Uint8Array([version, 0]);
1605-
if (isSpeedTestSite(hostname)) {
1605+
if (isSpeedTestSite(hostname) && 反代上下文.代理类型 === null) {
16061606
await 启用WS本地测速模式(serverSock, respHeader, rawClientData);
16071607
return;
16081608
}

0 commit comments

Comments
 (0)