mirror of
https://github.com/XIU2/CloudflareSpeedTest.git
synced 2026-03-27 19:29:02 +08:00
修复 下载测速时间不准确、卡住的问题
This commit is contained in:
4
main.go
4
main.go
@@ -138,10 +138,6 @@ func main() {
|
|||||||
var data_2 = make([]CloudflareIPData, 0)
|
var data_2 = make([]CloudflareIPData, 0)
|
||||||
downloadTestTime = time.Duration(downloadSecond) * time.Second
|
downloadTestTime = time.Duration(downloadSecond) * time.Second
|
||||||
|
|
||||||
//println(downloadTestCount)
|
|
||||||
//println(downloadTestTime)
|
|
||||||
//println(downloadSecond)
|
|
||||||
|
|
||||||
fmt.Println("# XIU2/CloudflareSpeedTest " + version + "\n")
|
fmt.Println("# XIU2/CloudflareSpeedTest " + version + "\n")
|
||||||
if ipv6Mode {
|
if ipv6Mode {
|
||||||
fmt.Println("开始延迟测速(模式:TCP IPv6,端口:" + strconv.Itoa(tcpPort) + "):")
|
fmt.Println("开始延迟测速(模式:TCP IPv6,端口:" + strconv.Itoa(tcpPort) + "):")
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ func DownloadSpeedHandler(ip net.IPAddr) (bool, float32) {
|
|||||||
Transport: nil,
|
Transport: nil,
|
||||||
CheckRedirect: nil,
|
CheckRedirect: nil,
|
||||||
Jar: nil,
|
Jar: nil,
|
||||||
Timeout: 0,
|
Timeout: downloadTestTime,
|
||||||
}
|
}
|
||||||
var fullAddress string
|
var fullAddress string
|
||||||
if ipv6Mode { // IPv6 需要加上 []
|
if ipv6Mode { // IPv6 需要加上 []
|
||||||
@@ -124,7 +124,6 @@ func DownloadSpeedHandler(ip net.IPAddr) (bool, float32) {
|
|||||||
DialContext: GetDialContextByAddr(fullAddress),
|
DialContext: GetDialContextByAddr(fullAddress),
|
||||||
}
|
}
|
||||||
response, err := client.Get(url)
|
response, err := client.Get(url)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, 0
|
return false, 0
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user