From bd6fbb9f1f6bc8c0a12e735062082f8515f162ee Mon Sep 17 00:00:00 2001 From: xiu2 <54703944+XIU2@users.noreply.github.com> Date: Sun, 12 Feb 2023 17:57:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=A4=A7=E5=B0=8F=E6=9C=AA=E7=9F=A5=E7=9A=84?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E6=B5=8B=E9=80=9F=E5=9C=B0=E5=9D=80=E6=97=B6?= =?UTF-8?q?=E5=A4=AA=E5=BF=AB=E4=B8=8B=E8=BD=BD=E5=AE=8C=E6=88=90=E4=BC=9A?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E6=B5=8B=E9=80=9F=E7=BB=93=E6=9E=9C=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E7=9A=84=E9=97=AE=E9=A2=98(=E5=A6=82=20speed.cloudfla?= =?UTF-8?q?re.com=20=E8=BF=99=E7=A7=8D=E5=AE=9E=E6=97=B6=E7=94=9F=E6=88=90?= =?UTF-8?q?=E7=9A=84)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- task/download.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/task/download.go b/task/download.go index 8ae5624..c6286e6 100644 --- a/task/download.go +++ b/task/download.go @@ -169,6 +169,8 @@ func downloadHandler(ip *net.IPAddr) float64 { if err != nil { if err != io.EOF { // 如果文件下载过程中遇到报错(如 Timeout),且并不是因为文件下载完了,则退出循环(终止测速) break + } else if contentLength == -1 { // 文件下载完成 且 文件大小未知,则退出循环(终止测速),例如:https://speed.cloudflare.com/__down?bytes=200000000 这样的,如果在 10 秒内就下载完成了,会导致测速结果明显偏低甚至显示为 0.00(下载速度太快时) + break } // 获取上个时间片 last_time_slice := timeStart.Add(timeSlice * time.Duration(timeCounter-1))