1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-29 17:41:15 +03:00

add test for tls connCheck #3025 (#3047)

* add a check for TLS connections.
This commit is contained in:
naiqianz
2024-07-12 11:16:21 +08:00
committed by GitHub
parent 8a0c59b101
commit 0858ed24e6
2 changed files with 23 additions and 0 deletions

View File

@ -3,6 +3,7 @@
package pool
import (
"crypto/tls"
"errors"
"io"
"net"
@ -16,6 +17,10 @@ func connCheck(conn net.Conn) error {
// Reset previous timeout.
_ = conn.SetDeadline(time.Time{})
// Check if tls.Conn.
if c, ok := conn.(*tls.Conn); ok {
conn = c.NetConn()
}
sysConn, ok := conn.(syscall.Conn)
if !ok {
return nil