Use a dynamic buffer to handle client Hello SNI detection

This commit is contained in:
Ludovic Fernandez 2021-06-18 19:24:17 +02:00 committed by GitHub
parent 95e0633b2f
commit 99a23b0414
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -15,6 +15,8 @@ import (
"github.com/traefik/traefik/v2/pkg/types"
)
const defaultBufSize = 4096
// Router is a TCP router.
type Router struct {
routingTable map[string]Handler
@ -228,6 +230,11 @@ func clientHelloServerName(br *bufio.Reader) (string, bool, string, error) {
}
recLen := int(hdr[3])<<8 | int(hdr[4]) // ignoring version in hdr[1:3]
if recordHeaderLen+recLen > defaultBufSize {
br = bufio.NewReaderSize(br, recordHeaderLen+recLen)
}
helloBytes, err := br.Peek(recordHeaderLen + recLen)
if err != nil {
log.Errorf("Error while Hello: %s", err)