Skip to content

Commit

Permalink
Remove direct read from TLS underlying conn (#3138) (#3154)
Browse files Browse the repository at this point in the history
Co-authored-by: Francesco Renzi <rentziass@github.com>
  • Loading branch information
vladvildanov and rentziass authored Oct 14, 2024
1 parent ad131f4 commit ec680ae
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 23 deletions.
5 changes: 0 additions & 5 deletions internal/pool/conn_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
package pool

import (
"crypto/tls"
"errors"
"io"
"net"
Expand All @@ -17,10 +16,6 @@ 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
Expand Down
18 changes: 0 additions & 18 deletions internal/pool/conn_check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
package pool

import (
"crypto/tls"
"net"
"net/http/httptest"
"time"
Expand All @@ -15,17 +14,12 @@ import (
var _ = Describe("tests conn_check with real conns", func() {
var ts *httptest.Server
var conn net.Conn
var tlsConn *tls.Conn
var err error

BeforeEach(func() {
ts = httptest.NewServer(nil)
conn, err = net.DialTimeout(ts.Listener.Addr().Network(), ts.Listener.Addr().String(), time.Second)
Expect(err).NotTo(HaveOccurred())
tlsTestServer := httptest.NewUnstartedServer(nil)
tlsTestServer.StartTLS()
tlsConn, err = tls.DialWithDialer(&net.Dialer{Timeout: time.Second}, tlsTestServer.Listener.Addr().Network(), tlsTestServer.Listener.Addr().String(), &tls.Config{InsecureSkipVerify: true})
Expect(err).NotTo(HaveOccurred())
})

AfterEach(func() {
Expand All @@ -39,23 +33,11 @@ var _ = Describe("tests conn_check with real conns", func() {
Expect(connCheck(conn)).To(HaveOccurred())
})

It("good tls conn check", func() {
Expect(connCheck(tlsConn)).NotTo(HaveOccurred())

Expect(tlsConn.Close()).NotTo(HaveOccurred())
Expect(connCheck(tlsConn)).To(HaveOccurred())
})

It("bad conn check", func() {
Expect(conn.Close()).NotTo(HaveOccurred())
Expect(connCheck(conn)).To(HaveOccurred())
})

It("bad tls conn check", func() {
Expect(tlsConn.Close()).NotTo(HaveOccurred())
Expect(connCheck(tlsConn)).To(HaveOccurred())
})

It("check conn deadline", func() {
Expect(conn.SetDeadline(time.Now())).NotTo(HaveOccurred())
time.Sleep(time.Millisecond * 10)
Expand Down

0 comments on commit ec680ae

Please sign in to comment.