mirror of
https://github.com/tailscale/tailscale.git
synced 2025-12-03 02:21:58 +00:00
net/{neterror,dns/resolver}: move PacketWasTruncated to neterror from DNS code
And delete the unused code in net/dns/resolver/neterr_*.go. Change-Id: Ibe62c486bacce2733eb9968c96a98cbbdb2758bd Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
dd45bba76b
commit
2513d2d728
@@ -40,3 +40,21 @@ func TreatAsLostUDP(err error) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var packetWasTruncated func(error) bool // non-nil on Windows at least
|
||||
|
||||
// PacketWasTruncated reports whether err indicates truncation but the RecvFrom
|
||||
// that generated err was otherwise successful. On Windows, Go's UDP RecvFrom
|
||||
// calls WSARecvFrom which returns the WSAEMSGSIZE error code when the received
|
||||
// datagram is larger than the provided buffer. When that happens, both a valid
|
||||
// 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.
|
||||
func PacketWasTruncated(err error) bool {
|
||||
if packetWasTruncated == nil {
|
||||
return false
|
||||
}
|
||||
return packetWasTruncated(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user