From c30bcfee111c59289f655bcca152eea9a49e80eb Mon Sep 17 00:00:00 2001 From: sjlleo Date: Wed, 8 Jun 2022 19:52:19 +0800 Subject: [PATCH] =?UTF-8?q?fix=20&=20improve:=20=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E7=9A=84=20IP=20=E9=94=99=E8=AF=AF=20?= =?UTF-8?q?=E8=B7=AF=E7=94=B1=E8=B7=9F=E8=B8=AA=E9=BB=98=E8=AE=A4=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fast_trace/basic.go | 12 +----------- fast_trace/fast_trace.go | 33 +++------------------------------ 2 files changed, 4 insertions(+), 41 deletions(-) diff --git a/fast_trace/basic.go b/fast_trace/basic.go index a40ca3a..d71b5a9 100644 --- a/fast_trace/basic.go +++ b/fast_trace/basic.go @@ -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", - }, -} \ No newline at end of file diff --git a/fast_trace/fast_trace.go b/fast_trace/fast_trace.go index 5154ec0..e82f0b1 100644 --- a/fast_trace/fast_trace.go +++ b/fast_trace/fast_trace.go @@ -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