From 089250fee1de4870cbdebd536c3d3459060f586f Mon Sep 17 00:00:00 2001 From: tsosunchia <59512455+tsosunchia@users.noreply.github.com> Date: Fri, 2 Jun 2023 01:32:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BE=9B=E4=B8=8D=E9=97=B4=E6=96=AD?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=E7=8E=AF=E5=A2=83=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/cmd.go | 9 +++++++++ ipgeo/leo.go | 2 +- util/latency.go | 6 +++++- util/util.go | 1 + 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/cmd/cmd.go b/cmd/cmd.go index b8620d5..2374d8d 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -236,6 +236,15 @@ func Excute() { conf.AsyncPrinter = nil } + if util.Uninterrupted != "" || *rawPrint { + for { + _, err := trace.Traceroute(m, conf) + if err != nil { + fmt.Println(err) + } + } + } + res, err := trace.Traceroute(m, conf) if err != nil { diff --git a/ipgeo/leo.go b/ipgeo/leo.go index d8b5382..2cbf0d6 100644 --- a/ipgeo/leo.go +++ b/ipgeo/leo.go @@ -58,7 +58,7 @@ func receiveParse() { m := make(map[string][]string) err := json.Unmarshal([]byte(res.Get("router").String()), &m) if err != nil { - return + // 此处是正常的,因为有些IP没有路由信息 } lat, _ := strconv.ParseFloat(res.Get("lat").String(), 32) diff --git a/util/latency.go b/util/latency.go index c54e483..21fd061 100644 --- a/util/latency.go +++ b/util/latency.go @@ -14,8 +14,12 @@ var ( result string results = make(chan string) ) +var FastIpCache = "" func GetFastIP(domain string, port string, enableOutput bool) string { + if FastIpCache != "" { + return FastIpCache + } ips, err := net.LookupIP(domain) if err != nil { @@ -44,7 +48,7 @@ func GetFastIP(domain string, port string, enableOutput bool) string { ) } } - + FastIpCache = res[0] return res[0] } diff --git a/util/util.go b/util/util.go index b82be37..dbb7cc5 100644 --- a/util/util.go +++ b/util/util.go @@ -13,6 +13,7 @@ import ( "github.com/fatih/color" ) +var Uninterrupted = GetenvDefault("NEXTTRACE_UNINTERRUPTED", "") var EnvToken = GetenvDefault("NEXTTRACE_TOKEN", "") var UserAgent = fmt.Sprintf("NextTrace %s/%s/%s", config.Version, runtime.GOOS, runtime.GOARCH)