feat: 添加IPV6初始化

This commit is contained in:
spiritlhl committed 2025-04-06 13:01:37 +00:00
1 parent c9c62e86f3
commit 3b19d43eef
3 files changed
+182 -22

No files matched your search

+39 -6
View File
@@ -6,24 +6,57 @@ import (
)
func BackTrace(test bool) {
if !test {
// 获取IP地址数量
ipCount := len(ipv4s)
if test {
ipv4Count := len(ipv4s)
ipv6Count := len(ipv6s)
totalCount := ipv4Count + ipv6Count
var (
s = make([]string, ipCount) // 动态分配切片大小
s = make([]string, totalCount)
c = make(chan Result)
t = time.After(time.Second * 10)
)
for i := range ipv4s {
go trace(c, i)
}
loop:
for i := range ipv6s {
go traceIPv6(c, i, ipv4Count)
}
loopIPv4v6:
for range s {
select {
case o := <-c:
s[o.i] = o.s
case <-t:
break loop
break loopIPv4v6
}
}
for i := 0; i < ipv4Count; i++ {
if s[i] != "" {
fmt.Println(s[i])
}
}
for i := ipv4Count; i < totalCount; i++ {
if s[i] != "" {
fmt.Println(s[i])
}
}
} else {
ipCount := len(ipv4s)
var (
s = make([]string, ipCount)
c = make(chan Result)
t = time.After(time.Second * 10)
)
for i := range ipv4s {
go trace(c, i)
}
loopIPv4:
for range s {
select {
case o := <-c:
s[o.i] = o.s
case <-t:
break loopIPv4
}
}
for _, r := range s {