diff --git a/cmd/cmd.go b/cmd/cmd.go index 39794c9..568cc35 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -89,11 +89,11 @@ func Excute() { fmt.Print(parser.Usage(err)) return } - + if strings.Contains(domain, "/") { domain = strings.Split(domain, "/")[2] } - + if strings.Contains(domain, "]") { domain = strings.Split(strings.Split(domain, "]")[0], "[")[1] } else if strings.Contains(domain, ":") { @@ -111,7 +111,7 @@ func Excute() { fmt.Println("NextTrace 基于 Windows 的路由跟踪还在早期开发阶段,目前还存在诸多问题,TCP/UDP SYN 包请求可能不能正常运行") } - if *tcp || *udp { + if *udp { ip = util.DomainLookUp(domain, true) } else { ip = util.DomainLookUp(domain, false) diff --git a/fast_trace/fast_trace ipv6.go b/fast_trace/fast_trace ipv6.go index 55bda97..a83fd4f 100644 --- a/fast_trace/fast_trace ipv6.go +++ b/fast_trace/fast_trace ipv6.go @@ -115,7 +115,12 @@ func FastTestv6(tm bool, outEnable bool) { w.Conn.Close() }() - ft.TracerouteMethod = trace.ICMPTrace + if !tm { + ft.TracerouteMethod = trace.ICMPTrace + fmt.Println("您将默认使用ICMP协议进行路由跟踪,如果您想使用TCP SYN进行路由跟踪,可以加入 -T 参数") + } else { + ft.TracerouteMethod = trace.TCPTrace + } switch c { case "1": diff --git a/util/util.go b/util/util.go index d323517..c4467da 100644 --- a/util/util.go +++ b/util/util.go @@ -51,34 +51,20 @@ func DomainLookUp(host string, ipv4Only bool) net.IP { os.Exit(1) } - var ipSlice = []net.IP{} var ipv6Flag = false - for _, ip := range ips { - ipSlice = append(ipSlice, ip) - // if ipv4Only { - // // 仅返回ipv4的ip - // if ip.To4() != nil { - // ipSlice = append(ipSlice, ip) - // } else { - // ipv6Flag = true - // } - // } else { - // ipSlice = append(ipSlice, ip) - // } - } if ipv6Flag { - fmt.Println("[Info] IPv6 TCP/UDP Traceroute is not supported right now.") - // if len(ipSlice) == 0 { - // os.Exit(0) - // } + fmt.Println("[Info] IPv6 UDP Traceroute is not supported right now.") + if len(ips) == 0 { + os.Exit(0) + } } - if len(ipSlice) == 1 { - return ipSlice[0] + if len(ips) == 1 { + return ips[0] } else { fmt.Println("Please Choose the IP You Want To TraceRoute") - for i, ip := range ipSlice { + for i, ip := range ips { fmt.Fprintf(color.Output, "%s %s\n", color.New(color.FgHiYellow, color.Bold).Sprintf("%d.", i), color.New(color.FgWhite, color.Bold).Sprintf("%s", ip), @@ -87,11 +73,11 @@ func DomainLookUp(host string, ipv4Only bool) net.IP { var index int fmt.Printf("Your Option: ") fmt.Scanln(&index) - if index >= len(ipSlice) || index < 0 { + if index >= len(ips) || index < 0 { fmt.Println("Your Option is invalid") os.Exit(3) } - return ipSlice[index] + return ips[index] } }