diff --git a/fast_trace/fast_trace ipv6.go b/fast_trace/fast_trace ipv6.go index c719a30..fb08fcf 100644 --- a/fast_trace/fast_trace ipv6.go +++ b/fast_trace/fast_trace ipv6.go @@ -13,6 +13,8 @@ import ( "os/signal" ) +var pFastTracer ParamsFastTrace + func (f *FastTracer) tracert_v6(location string, ispCollection ISPCollection) { fp, err := os.OpenFile("/tmp/trace.log", os.O_CREATE|os.O_APPEND|os.O_RDWR, os.ModePerm) if err != nil { @@ -29,25 +31,24 @@ func (f *FastTracer) tracert_v6(location string, ispCollection ISPCollection) { log.SetFlags(0) fmt.Printf("%s『%s %s 』%s\n", printer.YELLOW_PREFIX, location, ispCollection.ISPName, printer.RESET_PREFIX) log.Printf("『%s %s 』\n", location, ispCollection.ISPName) - fmt.Printf("traceroute to %s, %d hops max, %d byte packets\n", ispCollection.IPv6, f.ParamsFastTrace.MaxHops, f.ParamsFastTrace.PktSize) - log.Printf("traceroute to %s, %d hops max, %d byte packets\n", ispCollection.IPv6, f.ParamsFastTrace.MaxHops, f.ParamsFastTrace.PktSize) - ip := util.DomainLookUp(ispCollection.IP, "6", "", true) + fmt.Printf("traceroute to %s, %d hops max, %d byte packets\n", ispCollection.IPv6, pFastTracer.MaxHops, pFastTracer.PktSize) + log.Printf("traceroute to %s, %d hops max, %d byte packets\n", ispCollection.IPv6, pFastTracer.MaxHops, pFastTracer.PktSize) + ip := util.DomainLookUp(ispCollection.IPv6, "6", "", true) var conf = trace.Config{ - BeginHop: f.ParamsFastTrace.BeginHop, + BeginHop: pFastTracer.BeginHop, DestIP: ip, DestPort: 80, - MaxHops: f.ParamsFastTrace.MaxHops, + MaxHops: pFastTracer.MaxHops, NumMeasurements: 3, ParallelRequests: 18, - RDns: f.ParamsFastTrace.RDns, - AlwaysWaitRDNS: f.ParamsFastTrace.AlwaysWaitRDNS, + RDns: pFastTracer.RDns, + AlwaysWaitRDNS: pFastTracer.AlwaysWaitRDNS, PacketInterval: 100, TTLInterval: 500, IPGeoSource: ipgeo.GetSource("LeoMoeAPI"), - Timeout: f.ParamsFastTrace.Timeout, - SrcAddr: f.ParamsFastTrace.SrcAddr, - PktSize: f.ParamsFastTrace.PktSize, - Lang: f.ParamsFastTrace.Lang, + Timeout: pFastTracer.Timeout, + PktSize: pFastTracer.PktSize, + Lang: pFastTracer.Lang, } if oe { @@ -102,10 +103,11 @@ func (f *FastTracer) testEDU_v6() { f.tracert_v6(TestIPsCollection.Hangzhou.Location, TestIPsCollection.Hangzhou.EDU) } -func FastTestv6(tm bool, outEnable bool) { +func FastTestv6(tm bool, outEnable bool, paramsFastTrace ParamsFastTrace) { var c string oe = outEnable + pFastTracer = paramsFastTrace fmt.Println("您想测试哪些ISP的路由?\n1. 国内四网\n2. 电信\n3. 联通\n4. 移动\n5. 教育网") fmt.Print("请选择选项:") diff --git a/fast_trace/fast_trace.go b/fast_trace/fast_trace.go index b6ef254..729185c 100644 --- a/fast_trace/fast_trace.go +++ b/fast_trace/fast_trace.go @@ -97,7 +97,7 @@ func FastTest(tm bool, outEnable bool, paramsFastTrace ParamsFastTrace) { c = "1" } if c == "2" { - FastTestv6(tm, outEnable) + FastTestv6(tm, outEnable, paramsFastTrace) return } diff --git a/fast_trace/fast_trace_test.go b/fast_trace/fast_trace_test.go index bf0f7db..bb55b11 100644 --- a/fast_trace/fast_trace_test.go +++ b/fast_trace/fast_trace_test.go @@ -31,7 +31,7 @@ func TestTrace(t *testing.T) { }() fmt.Println("TCP v4") ft.TracerouteMethod = trace.TCPTrace - ft.tracert(TestIPsCollection.Beijing.Location, TestIPsCollection.Beijing.EDU) + //ft.tracert(TestIPsCollection.Beijing.Location, TestIPsCollection.Beijing.EDU) //fmt.Println("TCP v6") //ft.tracert_v6(TestIPsCollection.Beijing.Location, TestIPsCollection.Beijing.EDU) //fmt.Println("ICMP v4") diff --git a/util/dns_test.go b/util/dns_test.go index bac2443..568d599 100644 --- a/util/dns_test.go +++ b/util/dns_test.go @@ -11,3 +11,10 @@ func TestDNS(t *testing.T) { ips, _ := resolver.LookupHost(context.Background(), "www.bing.com") fmt.Println(ips) } + +func TestDomainLookUp(t *testing.T) { + ips := DomainLookUp("pek-4134.nexttrace-io-fasttrace-endpoint.win.", "all", "", false) + fmt.Println(ips) + ips = DomainLookUp("pek-4134.nexttrace-io-fasttrace-endpoint.win.", "4", "", false) + fmt.Println(ips) +} diff --git a/util/util.go b/util/util.go index d660ad9..eaaadc1 100644 --- a/util/util.go +++ b/util/util.go @@ -93,8 +93,8 @@ func DomainLookUp(host string, ipVersion string, dotServer string, disableOutput default: r = newUDPResolver() } - ips_str, err := r.LookupHost(context.Background(), host) - for _, v := range ips_str { + ipsStr, err := r.LookupHost(context.Background(), host) + for _, v := range ipsStr { ips = append(ips, net.ParseIP(v)) } if err != nil {