Quiet down TCP RST packet error on read operation

This commit is contained in:
Romain 2022-09-14 11:50:08 +02:00 committed by GitHub
parent ab8d7d2e78
commit 89dc466b23
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 58 additions and 2 deletions

16
pkg/tcp/proxy_unix.go Normal file
View file

@ -0,0 +1,16 @@
//go:build !windows
// +build !windows
package tcp
import (
"errors"
"net"
"syscall"
)
// isReadConnResetError reports whether err is a connection reset error during a read operation.
func isReadConnResetError(err error) bool {
var oerr *net.OpError
return errors.As(err, &oerr) && oerr.Op == "read" && errors.Is(err, syscall.ECONNRESET)
}