From b8f423f08d68a9efbe92c017a8790a45d88c1eb9 Mon Sep 17 00:00:00 2001 From: cmliu Date: Sun, 14 Dec 2025 13:37:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=9B=B4=E6=96=B0forwardataTCP=E5=87=BD?= =?UTF-8?q?=E6=95=B0=EF=BC=8C=E9=9A=8F=E6=9C=BA=E5=8C=96=E5=8F=8D=E4=BB=A3?= =?UTF-8?q?=E5=9C=B0=E5=9D=80=E9=80=89=E6=8B=A9=E4=BB=A5=E6=8F=90=E9=AB=98?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E6=88=90=E5=8A=9F=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _worker.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/_worker.js b/_worker.js index e93c60e..e70aff4 100644 --- a/_worker.js +++ b/_worker.js @@ -502,7 +502,10 @@ async function forwardataTCP(host, portNum, rawData, ws, respHeader, remoteConnW async function connectDirect(address, port, data, 所有反代数组 = null) { let remoteSock; if (所有反代数组 && 所有反代数组.length > 0) { - for (const [反代地址, 反代端口] of 所有反代数组) { + const 打乱后数组 = [...所有反代数组].sort(() => Math.random() - 0.5); + const 最大尝试次数 = Math.min(8, 打乱后数组.length); + for (let i = 0; i < 最大尝试次数; i++) { + const [反代地址, 反代端口] = 打乱后数组[i]; try { remoteSock = connect({ hostname: 反代地址, port: 反代端口 }); const testWriter = remoteSock.writable.getWriter();