fix: 减少无效日志输出,对齐V4和V6的输出

This commit is contained in:
spiritlhl committed 2025-04-08 14:18:20 +00:00
1 parent 93434aeda1
commit ddc2f9b401
5 files changed
+146 -174

No files matched your search

+1 -28
View File
@@ -10,33 +10,6 @@ import (
"golang.org/x/net/ipv6"
)
// func newPacketV6(id uint16, dst net.IP, ttl int) []byte {
// // 创建ICMP消息(回显请求)
// msg := icmp.Message{
// Type: ipv6.ICMPTypeEchoRequest,
// Body: &icmp.Echo{
// ID: int(id),
// Seq: int(id),
// },
// }
// // 序列化ICMP消息
// icmpData, _ := msg.Marshal(nil)
// // 手动创建原始IPv6数据包头部
// ipHeaderBytes := make([]byte, ipv6.HeaderLen)
// // 设置版本和流量类别(第一个字节)
// ipHeaderBytes[0] = (ipv6.Version << 4)
// // 设置下一个头部(协议)
// ipHeaderBytes[6] = ProtocolIPv6ICMP
// // 设置跳数限制
// ipHeaderBytes[7] = byte(ttl)
// // 设置有效载荷长度(2字节字段)
// binary.BigEndian.PutUint16(ipHeaderBytes[4:6], uint16(len(icmpData)))
// // 设置目标地址(最后16个字节)
// copy(ipHeaderBytes[24:40], dst.To16())
// // 合并头部和ICMP数据
// return append(ipHeaderBytes, icmpData...)
// }
func newPacketV6(id uint16, dst net.IP, ttl int) []byte {
// 使用ipv6包的Echo请求
msg := icmp.Message{
@@ -88,7 +61,7 @@ func traceIPv6(ch chan Result, i int, offset int) {
}
hops, err := Trace(net.ParseIP(ipv6s[i]))
if err != nil {
s := fmt.Sprintf("%v %-40s %v", ipv6Names[i], ipv6s[i], err)
s := fmt.Sprintf("%v %-25s %v", ipv6Names[i], ipv6s[i], err)
if EnableLoger {
Logger.Error(fmt.Sprintf("追踪 %s (%s) 失败: %v", ipv6Names[i], ipv6s[i], err))
}