chore: IPv6 TCP Tracert Support for Fast Trace

This commit is contained in:
Leo
2023-02-15 18:41:59 +08:00
parent 5c0c490ae8
commit 9871449b30
3 changed files with 18 additions and 27 deletions

View File

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

View File

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

View File

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