Remove deadlines for non-TLS connections

Co-authored-by: Kevin Pollet <pollet.kevin@gmail.com>
This commit is contained in:
Romain 2024-04-15 17:02:06 +02:00 committed by GitHub
parent b9b7527762
commit 70968bc6a9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -100,6 +100,11 @@ func (r *Router) ServeTCP(conn tcp.WriteCloser) {
// If there is a handler matching the connection metadata,
// we let it handle the connection.
if handler != nil {
// Remove read/write deadline and delegate this to underlying TCP server.
if err := conn.SetDeadline(time.Time{}); err != nil {
log.WithoutContext().Errorf("Error while setting deadline: %v", err)
}
handler.ServeTCP(conn)
return
}
@ -117,15 +122,9 @@ func (r *Router) ServeTCP(conn tcp.WriteCloser) {
return
}
// Remove read/write deadline and delegate this to underlying tcp server (for now only handled by HTTP Server)
err = conn.SetReadDeadline(time.Time{})
if err != nil {
log.WithoutContext().Errorf("Error while setting read deadline: %v", err)
}
err = conn.SetWriteDeadline(time.Time{})
if err != nil {
log.WithoutContext().Errorf("Error while setting write deadline: %v", err)
// Remove read/write deadline and delegate this to underlying TCP server (for now only handled by HTTP Server)
if err := conn.SetDeadline(time.Time{}); err != nil {
log.WithoutContext().Errorf("Error while setting deadline: %v", err)
}
connData, err := tcpmuxer.NewConnData(hello.serverName, conn, hello.protos)