mirror of
https://github.com/oneclickvirt/backtrace.git
synced 2025-04-22 04:02:07 +08:00
feat: 尝试添加IPV6路由追踪
This commit is contained in:
parent
0c6b11883f
commit
7efc61cbe4
30
bk/trace_ipv6.go
Normal file
30
bk/trace_ipv6.go
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package bk
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net"
|
||||||
|
|
||||||
|
"golang.org/x/net/icmp"
|
||||||
|
"golang.org/x/net/ipv6"
|
||||||
|
)
|
||||||
|
|
||||||
|
func newPacketV6(id uint16, dst net.IP, ttl int) []byte {
|
||||||
|
msg := icmp.Message{
|
||||||
|
Type: ipv6.ICMPTypeEchoRequest,
|
||||||
|
Body: &icmp.Echo{
|
||||||
|
ID: int(id),
|
||||||
|
Seq: int(id),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
p, _ := msg.Marshal(nil)
|
||||||
|
ip := &ipv6.Header{
|
||||||
|
Version: ipv6.Version,
|
||||||
|
NextHeader: ProtocolIPv6ICMP,
|
||||||
|
HopLimit: ttl,
|
||||||
|
Dst: dst,
|
||||||
|
}
|
||||||
|
buf, err := ip.Marshal()
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return append(buf, p...)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user