mirror of
https://github.com/nxtrace/NTrace-core.git
synced 2025-08-12 06:26:39 +00:00
chore: IPv6 TCP Tracert Support for Fast Trace
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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":
|
||||
|
||||
32
util/util.go
32
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]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user