From f6288f4e5266c7a47f9ac3b52d6f37a3724be6b8 Mon Sep 17 00:00:00 2001 From: mz <2392368224@qq.com> Date: Sun, 14 Nov 2021 14:10:44 +0800 Subject: [PATCH] tcphandler just test one ip --- task/tcping.go | 35 +++++------------------------------ 1 file changed, 5 insertions(+), 30 deletions(-) diff --git a/task/tcping.go b/task/tcping.go index 69dd684..fc5f9de 100644 --- a/task/tcping.go +++ b/task/tcping.go @@ -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) { - ipCanConnect := false - 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 - } - } + recv, totalDlay := p.checkConnection(ip) p.bar.Grow(1) - if !ipCanConnect { + if recv == 0 { return } - // for i := 0; i < PingTimes; i++ { - // pingSuccess, pingTimeCurrent := p.tcping(ip) - // progressHandler(utils.NormalPing) - // if pingSuccess { - // pingRecv++ - // pingTime += pingTimeCurrent - // } - // } data := &utils.PingData{ IP: ip, Sended: PingTimes, - Received: pingRecv, - Delay: delay / time.Duration(pingRecv), + Received: recv, + Delay: totalDlay / time.Duration(recv), } p.appendIPData(data) - return }