Don't log EOF or timeout errors while peeking first bytes in Postgres StartTLS hook

This commit is contained in:
Romain 2023-01-12 12:28:04 +01:00 committed by GitHub
parent f94298e867
commit 707f84e2e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,6 +4,8 @@ import (
"bufio" "bufio"
"bytes" "bytes"
"errors" "errors"
"io"
"net"
"sync" "sync"
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"
@ -25,7 +27,10 @@ func isPostgres(br *bufio.Reader) (bool, error) {
for i := 1; i < len(PostgresStartTLSMsg)+1; i++ { for i := 1; i < len(PostgresStartTLSMsg)+1; i++ {
peeked, err := br.Peek(i) peeked, err := br.Peek(i)
if err != nil { if err != nil {
log.Error().Err(err).Msg("Error while Peeking first bytes") var opErr *net.OpError
if !errors.Is(err, io.EOF) && (!errors.As(err, &opErr) || opErr.Timeout()) {
log.Error().Err(err).Msg("Error while Peeking first byte")
}
return false, err return false, err
} }