Update
This commit is contained in:
1 parent
3530afb854
commit
6903fcff27
2146 files changed
+112256
-190703
No files matched your search
+3
-3
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) Tailscale Inc & AUTHORS
|
||||
// Copyright (c) Tailscale Inc & contributors
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
// Package neterror classifies network errors.
|
||||
@@ -50,8 +50,8 @@ var packetWasTruncated func(error) bool // non-nil on Windows at least
|
||||
// size and an error are returned (as per the partial fix for golang/go#14074).
|
||||
// If the WSAEMSGSIZE error is returned, then we ignore the error to get
|
||||
// semantics similar to the POSIX operating systems. One caveat is that it
|
||||
// appears that the source address is not returned when WSAEMSGSIZE occurs, but
|
||||
// we do not currently look at the source address.
|
||||
// appears that the source address is not returned when WSAEMSGSIZE occurs, so
|
||||
// a caller can't check where a truncated datagram came from.
|
||||
func PacketWasTruncated(err error) bool {
|
||||
if packetWasTruncated == nil {
|
||||
return false
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// Copyright (c) Tailscale Inc & contributors
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
//go:build js || wasip1 || wasm
|
||||
|
||||
package neterror
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"io/fs"
|
||||
)
|
||||
|
||||
// Reports whether err resulted from reading or writing to a closed or broken pipe.
|
||||
func IsClosedPipeError(err error) bool {
|
||||
// Libraries may also return root errors like fs.ErrClosed/io.ErrClosedPipe
|
||||
// due to a closed socket.
|
||||
return errors.Is(err, fs.ErrClosed) ||
|
||||
errors.Is(err, io.ErrClosedPipe)
|
||||
}
|
||||
+2
-3
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) Tailscale Inc & AUTHORS
|
||||
// Copyright (c) Tailscale Inc & contributors
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
package neterror
|
||||
@@ -12,8 +12,7 @@ import (
|
||||
|
||||
func init() {
|
||||
shouldDisableUDPGSO = func(err error) bool {
|
||||
var serr *os.SyscallError
|
||||
if errors.As(err, &serr) {
|
||||
if serr, ok := errors.AsType[*os.SyscallError](err); ok {
|
||||
// EIO is returned by udp_send_skb() if the device driver does not
|
||||
// have tx checksumming enabled, which is a hard requirement of
|
||||
// UDP_SEGMENT. See:
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// Copyright (c) Tailscale Inc & contributors
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
//go:build plan9
|
||||
|
||||
package neterror
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"io/fs"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Reports whether err resulted from reading or writing to a closed or broken pipe.
|
||||
func IsClosedPipeError(err error) bool {
|
||||
// Libraries may also return root errors like fs.ErrClosed/io.ErrClosedPipe
|
||||
// due to a closed socket.
|
||||
// For a raw syscall error, check for error string containing "closed pipe",
|
||||
// per the note set by the system: https://9p.io/magic/man2html/2/pipe
|
||||
return errors.Is(err, fs.ErrClosed) ||
|
||||
errors.Is(err, io.ErrClosedPipe) ||
|
||||
strings.Contains(err.Error(), "closed pipe")
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
// Copyright (c) Tailscale Inc & contributors
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
//go:build !plan9 && !js && !wasip1 && !wasm
|
||||
|
||||
package neterror
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"io/fs"
|
||||
"runtime"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// Reports whether err resulted from reading or writing to a closed or broken pipe.
|
||||
func IsClosedPipeError(err error) bool {
|
||||
// 232 is Windows error code ERROR_NO_DATA, "The pipe is being closed".
|
||||
if runtime.GOOS == "windows" && errors.Is(err, syscall.Errno(232)) {
|
||||
return true
|
||||
}
|
||||
|
||||
// EPIPE/ENOTCONN are common errors when a send fails due to a closed
|
||||
// socket. There is some platform and version inconsistency in which
|
||||
// error is returned, but the meaning is the same.
|
||||
// Libraries may also return root errors like fs.ErrClosed/io.ErrClosedPipe
|
||||
// due to a closed socket.
|
||||
return errors.Is(err, syscall.EPIPE) ||
|
||||
errors.Is(err, syscall.ENOTCONN) ||
|
||||
errors.Is(err, fs.ErrClosed) ||
|
||||
errors.Is(err, io.ErrClosedPipe)
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) Tailscale Inc & AUTHORS
|
||||
// Copyright (c) Tailscale Inc & contributors
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
package neterror
|
||||
|
||||
Reference in new issue
Block a user