From b082d05381ab0ed84486ad4c34582365972efcdb Mon Sep 17 00:00:00 2001 From: Erik Geiser Date: Tue, 22 Jun 2021 11:00:27 +0200 Subject: [PATCH] Skip SetChecksum on Windows --- conn.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/conn.go b/conn.go index d520bba..16bb112 100644 --- a/conn.go +++ b/conn.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "net" + "runtime" "time" "golang.org/x/net/icmp" @@ -63,10 +64,13 @@ func Dial(ifi *net.Interface, addr Addr) (*Conn, net.IP, error) { return nil, nil, err } - // Calculate and place ICMPv6 checksum at correct offset in all messages. - const chkOff = 2 - if err := pc.SetChecksum(true, chkOff); err != nil { - return nil, nil, err + if runtime.GOOS != "windows" { + // Calculate and place ICMPv6 checksum at correct offset in all + // messages (not implemented by golang.org/x/net/ipv6 on Windows). + const chkOff = 2 + if err := pc.SetChecksum(true, chkOff); err != nil { + return nil, nil, fmt.Errorf("set checksum: %w", err) + } } return newConn(pc, ipAddr, ifi)