mirror of
https://github.com/nxtrace/NTrace-core.git
synced 2025-08-12 06:26:39 +00:00
fix & improve: 测试节点的 IP 错误 路由跟踪默认配置优化
This commit is contained in:
@@ -40,7 +40,6 @@ var TestIPsCollection = AllLocationCollection{
|
||||
Guangzhou: Guangzhou,
|
||||
Hangzhou: Hangzhou,
|
||||
Hefei: Hefei,
|
||||
Changsha: Changsha,
|
||||
}
|
||||
|
||||
var Beijing = BackBoneCollection{
|
||||
@@ -108,7 +107,7 @@ var Guangzhou = BackBoneCollection{
|
||||
|
||||
CU169: ISPCollection{
|
||||
ISPName: CU169,
|
||||
IP: "123.125.96.156",
|
||||
IP: "157.18.0.22",
|
||||
},
|
||||
|
||||
CM: ISPCollection{
|
||||
@@ -151,12 +150,3 @@ var Hefei = BackBoneCollection{
|
||||
IP: "210.72.22.2",
|
||||
},
|
||||
}
|
||||
|
||||
var Changsha = BackBoneCollection{
|
||||
Location: "长沙",
|
||||
// 中南大学 教育网
|
||||
EDU: ISPCollection{
|
||||
ISPName: EDU,
|
||||
IP: "202.197.61.221",
|
||||
},
|
||||
}
|
||||
@@ -6,15 +6,12 @@ import (
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"github.com/xgadget-lab/nexttrace/config"
|
||||
"github.com/xgadget-lab/nexttrace/ipgeo"
|
||||
"github.com/xgadget-lab/nexttrace/printer"
|
||||
"github.com/xgadget-lab/nexttrace/reporter"
|
||||
"github.com/xgadget-lab/nexttrace/trace"
|
||||
)
|
||||
|
||||
type FastTracer struct {
|
||||
Preference config.Preference
|
||||
TracerouteMethod trace.Method
|
||||
}
|
||||
|
||||
@@ -28,8 +25,8 @@ func (f *FastTracer) tracert(location string, ispCollection ISPCollection) {
|
||||
MaxHops: 30,
|
||||
NumMeasurements: 3,
|
||||
ParallelRequests: 18,
|
||||
RDns: !f.Preference.NoRDNS,
|
||||
IPGeoSource: ipgeo.GetSource(f.Preference.DataOrigin),
|
||||
RDns: true,
|
||||
IPGeoSource: ipgeo.GetSource("LeoMoeAPI"),
|
||||
Timeout: 1 * time.Second,
|
||||
}
|
||||
|
||||
@@ -46,29 +43,6 @@ func (f *FastTracer) tracert(location string, ispCollection ISPCollection) {
|
||||
if f.TracerouteMethod == trace.TCPTrace {
|
||||
printer.TracerouteTablePrinter(res)
|
||||
}
|
||||
|
||||
if f.Preference.AlwaysRoutePath {
|
||||
r := reporter.New(res, ip.String())
|
||||
r.Print()
|
||||
}
|
||||
}
|
||||
|
||||
func initialize() *FastTracer {
|
||||
configData, err := config.Read()
|
||||
|
||||
// Initialize Default Config
|
||||
if err != nil || configData.DataOrigin == "" {
|
||||
if configData, err = config.AutoGenerate(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Set Token from Config
|
||||
ipgeo.SetToken(configData.Token)
|
||||
|
||||
return &FastTracer{
|
||||
Preference: configData.Preference,
|
||||
}
|
||||
}
|
||||
|
||||
func (f *FastTracer) testAll() {
|
||||
@@ -108,7 +82,6 @@ func (f *FastTracer) testEDU() {
|
||||
f.tracert(TestIPsCollection.Hefei.Location, TestIPsCollection.Hefei.EDU)
|
||||
// 科技网暂时算在EDU里面,等拿到了足够多的数据再分离出去,单独用于测试
|
||||
f.tracert(TestIPsCollection.Hefei.Location, TestIPsCollection.Hefei.CST)
|
||||
f.tracert(TestIPsCollection.Changsha.Location, TestIPsCollection.Changsha.EDU)
|
||||
}
|
||||
|
||||
func FastTest(tm bool) {
|
||||
@@ -118,7 +91,7 @@ func FastTest(tm bool) {
|
||||
fmt.Print("请选择选项:")
|
||||
fmt.Scanln(&c)
|
||||
|
||||
ft := initialize()
|
||||
ft := FastTracer{}
|
||||
|
||||
if !tm {
|
||||
ft.TracerouteMethod = trace.ICMPTrace
|
||||
|
||||
Reference in New Issue
Block a user