mirror of
https://github.com/XIU2/CloudflareSpeedTest.git
synced 2026-04-20 13:16:26 +08:00
tcphandler just test one ip
This commit is contained in:
@@ -120,43 +120,18 @@ func (p *Ping) appendIPData(data *utils.PingData) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
//return Success packetRecv averagePingTime specificIPAddr
|
// handle tcping
|
||||||
func (p *Ping) tcpingHandler(ip *net.IPAddr) {
|
func (p *Ping) tcpingHandler(ip *net.IPAddr) {
|
||||||
ipCanConnect := false
|
recv, totalDlay := p.checkConnection(ip)
|
||||||
pingRecv := 0
|
|
||||||
var delay time.Duration
|
|
||||||
for !ipCanConnect {
|
|
||||||
recv, totalDlay := p.checkConnection(ip)
|
|
||||||
if recv > 0 {
|
|
||||||
ipCanConnect = true
|
|
||||||
pingRecv = recv
|
|
||||||
delay = totalDlay
|
|
||||||
} else {
|
|
||||||
ip.IP[15]++
|
|
||||||
if ip.IP[15] == 0 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p.bar.Grow(1)
|
p.bar.Grow(1)
|
||||||
if !ipCanConnect {
|
if recv == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// for i := 0; i < PingTimes; i++ {
|
|
||||||
// pingSuccess, pingTimeCurrent := p.tcping(ip)
|
|
||||||
// progressHandler(utils.NormalPing)
|
|
||||||
// if pingSuccess {
|
|
||||||
// pingRecv++
|
|
||||||
// pingTime += pingTimeCurrent
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
data := &utils.PingData{
|
data := &utils.PingData{
|
||||||
IP: ip,
|
IP: ip,
|
||||||
Sended: PingTimes,
|
Sended: PingTimes,
|
||||||
Received: pingRecv,
|
Received: recv,
|
||||||
Delay: delay / time.Duration(pingRecv),
|
Delay: totalDlay / time.Duration(recv),
|
||||||
}
|
}
|
||||||
p.appendIPData(data)
|
p.appendIPData(data)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user