mirror of
https://github.com/nxtrace/NTrace-core.git
synced 2025-08-12 06:26:39 +00:00
fix: crash when geo struct is not initialized.
This commit is contained in:
@@ -2,8 +2,10 @@ package printer
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"github.com/xgadget-lab/nexttrace/ipgeo"
|
||||
"github.com/xgadget-lab/nexttrace/trace"
|
||||
)
|
||||
|
||||
@@ -63,7 +65,8 @@ func makeHopsType(res *trace.Result, ttl int) map[int]HopInfo {
|
||||
// 创建一个字典,存放所有当前TTL的跃点类型集合
|
||||
hopProbesMap := make(map[int]HopInfo)
|
||||
for i := range res.Hops[ttl] {
|
||||
if res.Hops[ttl][i].Address != nil {
|
||||
// 判断是否Hops以及Geo结构体已经初始化
|
||||
if res.Hops[ttl][i].Address != nil && reflect.DeepEqual(res.Hops[ttl][i].Geo, ipgeo.IPGeoData{}) {
|
||||
if availableTTL := findLatestAvailableHop(res, ttl, i); availableTTL != -1 {
|
||||
switch {
|
||||
case strings.Contains(res.Hops[ttl][i].Geo.District, "IXP") || strings.Contains(strings.ToLower(res.Hops[ttl][i].Hostname), "ix"):
|
||||
|
||||
Reference in New Issue
Block a user