fix & improve: 测试节点的 IP 错误 路由跟踪默认配置优化

This commit is contained in:
sjlleo
2022-06-08 19:52:19 +08:00
parent 1554565460
commit c30bcfee11
2 changed files with 4 additions and 41 deletions

View File

@@ -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",
},
}

View File

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