mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-27 20:50:00 +00:00
TUN-6654: Support ICMPv6 on Linux and Darwin
This commit is contained in:
@@ -113,8 +113,15 @@ type echoReply struct {
|
||||
}
|
||||
|
||||
func parseReply(from net.Addr, rawMsg []byte) (*echoReply, error) {
|
||||
// TODO: TUN-6654 Check for IPv6
|
||||
msg, err := icmp.ParseMessage(int(layers.IPProtocolICMPv4), rawMsg)
|
||||
fromAddr, ok := netipAddr(from)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("cannot convert %s to netip.Addr", from)
|
||||
}
|
||||
proto := layers.IPProtocolICMPv4
|
||||
if fromAddr.Is6() {
|
||||
proto = layers.IPProtocolICMPv6
|
||||
}
|
||||
msg, err := icmp.ParseMessage(int(proto), rawMsg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -122,10 +129,6 @@ func parseReply(from net.Addr, rawMsg []byte) (*echoReply, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fromAddr, ok := netipAddr(from)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("cannot convert %s to netip.Addr", from)
|
||||
}
|
||||
return &echoReply{
|
||||
from: fromAddr,
|
||||
msg: msg,
|
||||
|
Reference in New Issue
Block a user