router.go (traefik-v2.3.2.src) | : | router.go (traefik-v2.3.3.src) | ||
---|---|---|---|---|
package tcp | package tcp | |||
import ( | import ( | |||
"bufio" | "bufio" | |||
"bytes" | "bytes" | |||
"crypto/tls" | "crypto/tls" | |||
"errors" | ||||
"io" | "io" | |||
"net" | "net" | |||
"net/http" | "net/http" | |||
"strings" | "strings" | |||
"time" | "time" | |||
"github.com/traefik/traefik/v2/pkg/log" | "github.com/traefik/traefik/v2/pkg/log" | |||
"github.com/traefik/traefik/v2/pkg/types" | "github.com/traefik/traefik/v2/pkg/types" | |||
) | ) | |||
skipping to change at line 200 | skipping to change at line 201 | |||
} | } | |||
return c.WriteCloser.Read(p) | return c.WriteCloser.Read(p) | |||
} | } | |||
// clientHelloServerName returns the SNI server name inside the TLS ClientHello, | // clientHelloServerName returns the SNI server name inside the TLS ClientHello, | |||
// without consuming any bytes from br. | // without consuming any bytes from br. | |||
// On any error, the empty string is returned. | // On any error, the empty string is returned. | |||
func clientHelloServerName(br *bufio.Reader) (string, bool, string, error) { | func clientHelloServerName(br *bufio.Reader) (string, bool, string, error) { | |||
hdr, err := br.Peek(1) | hdr, err := br.Peek(1) | |||
if err != nil { | if err != nil { | |||
opErr, ok := err.(*net.OpError) | var opErr *net.OpError | |||
if err != io.EOF && (!ok || !opErr.Timeout()) { | if !errors.Is(err, io.EOF) && (!errors.As(err, &opErr) || opErr.T | |||
imeout()) { | ||||
log.WithoutContext().Debugf("Error while Peeking first by te: %s", err) | log.WithoutContext().Debugf("Error while Peeking first by te: %s", err) | |||
} | } | |||
return "", false, "", err | return "", false, "", err | |||
} | } | |||
// No valid TLS record has a type of 0x80, however SSLv2 handshakes | // No valid TLS record has a type of 0x80, however SSLv2 handshakes | |||
// start with a uint16 length where the MSB is set and the first record | // start with a uint16 length where the MSB is set and the first record | |||
// is always < 256 bytes long. Therefore typ == 0x80 strongly suggests | // is always < 256 bytes long. Therefore typ == 0x80 strongly suggests | |||
// an SSLv2 client. | // an SSLv2 client. | |||
const recordTypeSSLv2 = 0x80 | const recordTypeSSLv2 = 0x80 | |||
const recordTypeHandshake = 0x16 | const recordTypeHandshake = 0x16 | |||
if hdr[0] != recordTypeHandshake { | if hdr[0] != recordTypeHandshake { | |||
End of changes. 3 change blocks. | ||||
2 lines changed or deleted | 5 lines changed or added |