From 707f84e2e4e70fca56207417d7d3d3bc252c1782 Mon Sep 17 00:00:00 2001 From: Romain Date: Thu, 12 Jan 2023 12:28:04 +0100 Subject: [PATCH] Don't log EOF or timeout errors while peeking first bytes in Postgres StartTLS hook --- pkg/server/router/tcp/postgres.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/server/router/tcp/postgres.go b/pkg/server/router/tcp/postgres.go index b79c3762f..02cb480a4 100644 --- a/pkg/server/router/tcp/postgres.go +++ b/pkg/server/router/tcp/postgres.go @@ -4,6 +4,8 @@ import ( "bufio" "bytes" "errors" + "io" + "net" "sync" "github.com/rs/zerolog/log" @@ -25,7 +27,10 @@ func isPostgres(br *bufio.Reader) (bool, error) { for i := 1; i < len(PostgresStartTLSMsg)+1; i++ { peeked, err := br.Peek(i) 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 }