From 9656dfe172ad239f95d6ddc85c97ee5de3e453c0 Mon Sep 17 00:00:00 2001 From: sjlleo Date: Fri, 27 May 2022 17:19:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=BD=9C=E5=9C=A8?= =?UTF-8?q?=E6=95=B0=E7=BB=84=E8=B6=8A=E7=95=8C=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- reporter/reporter.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/reporter/reporter.go b/reporter/reporter.go index 3309d4f3..26b5e6ac 100644 --- a/reporter/reporter.go +++ b/reporter/reporter.go @@ -130,7 +130,16 @@ func (r *reporter) InitialBaseData() Reporter { func (r *reporter) Print() { var beforeActiveTTL uint16 = 0 r.InitialBaseData() - for i := uint16(1); i < r.targetTTL; i++ { + // 尝试首个有效 TTL + for i := uint16(0); i < r.targetTTL; i++ { + if len(r.routeReport[i]) != 0 { + beforeActiveTTL = i + // 找到以后便不再循环 + break + } + } + + for i := beforeActiveTTL; i < r.targetTTL; i++ { // 计算该TTL内的数据长度,如果为0,则代表没有有效数据 if len(r.routeReport[i]) == 0 { // 跳过改跃点的数据整理 @@ -138,7 +147,7 @@ func (r *reporter) Print() { } nodeReport := r.routeReport[i][0] - if i == 1 { + if i == beforeActiveTTL { fmt.Printf("AS%s %s「%s『%s", nodeReport.asn, nodeReport.isp, nodeReport.geo[0], nodeReport.geo[1]) } else { nodeReportBefore := r.routeReport[beforeActiveTTL][0]