提供不间断运行环境变量

This commit is contained in:
tsosunchia
2023-06-02 01:32:56 +08:00
parent 0e87592537
commit 089250fee1
4 changed files with 16 additions and 2 deletions

View File

@@ -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 {

View File

@@ -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)

View File

@@ -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]
}

View File

@@ -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)