fix: producing timeout error in case with no timeout errors (#180)

Co-authored-by: Anton Piunov <anton.piunov@cyberprotect.ru>
This commit is contained in:
Tony 2024-08-21 14:48:52 +03:00 committed by GitHub
parent 87161e0538
commit d97d4e483c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -22,8 +22,9 @@ func ReadBytes(conn *net.TCPConn, dest []byte) ([]byte, error) {
func readBytesInternal(conn *net.TCPConn, dest []byte) (int, error) { func readBytesInternal(conn *net.TCPConn, dest []byte) (int, error) {
totalRead, err := conn.Read(dest) totalRead, err := conn.Read(dest)
if err != nil { if err != nil {
switch err.(type) { var opError *net.OpError
case *net.OpError: switch {
case errors.As(err, &opError) && opError.Timeout():
return totalRead, errors.New("timed out") return totalRead, errors.New("timed out")
default: default:
return totalRead, err return totalRead, err