Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
Signed-off-by: xhe <[email protected]>
  • Loading branch information
xhebox committed Dec 1, 2023
1 parent 903f698 commit cdf33ef
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions pkg/proxy/backend/authenticator.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"encoding/binary"
"fmt"
"net"
"strings"

"github.com/go-mysql-org/go-mysql/mysql"
"github.com/pingcap/tidb/util/hack"
Expand Down Expand Up @@ -212,11 +213,6 @@ loop:
for {
serverPkt, err := backendIO.ReadPacket()
if err != nil {
// tiproxy pp enabled, tidb pp disabled, tls disabled => invalid sequence
// tiproxy pp disabled, tidb pp enabled, tls disabled => invalid sequence
if pktIdx == 0 {
return errors.Wrap(ErrBackendPPV2, err)
}
return err
}
var packetErr *mysql.MyError
Expand All @@ -235,6 +231,18 @@ loop:
return err
}
if packetErr != nil {
// tiproxy pp enabled, tidb pp disabled, tls disabled => invalid sequence
// tiproxy pp disabled, tidb pp enabled, tls disabled => invalid sequence
for _, p := range []string{
"packets out of order",
"(nvali): d sequence",
"invalid sequence",
"PROXY Protocol",
} {
if strings.Contains(packetErr.Message, p) {
return errors.Wrap(ErrBackendPPV2, packetErr)
}
}
return errors.Wrap(ErrClientAuthFail, packetErr)
}

Expand Down

0 comments on commit cdf33ef

Please sign in to comment.