Skip to content

Commit f79125f

Browse files
author
gal
committed
fixed tls recv bug
1 parent 04294ce commit f79125f

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

clients/http2client.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ func (client *Http2Client) Connect() error {
109109
return nil
110110
}
111111

112-
// getTCPConn tries to unwrap the net.Conn to get the underlying *net.TCPConn
113-
func getTCPConn(c net.Conn) (*net.TCPConn, error) {
112+
// GetTCPConn tries to unwrap the net.Conn to get the underlying *net.TCPConn
113+
func GetTCPConn(c net.Conn) (*net.TCPConn, error) {
114114
switch conn := c.(type) {
115115
case *net.TCPConn:
116116
return conn, nil
@@ -132,7 +132,7 @@ func (client *Http2Client) CloseFIN() error {
132132
return fmt.Errorf("connection is already closed")
133133
}
134134
//time.Sleep(time.Second * 1)
135-
conn, err := getTCPConn(client.conn)
135+
conn, err := GetTCPConn(client.conn)
136136
if err != nil {
137137
return fmt.Errorf("error getting TCP connection: %v", err)
138138
}

clients/repeaterClientBase.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package clients
22

33
import (
4+
"crypto/tls"
45
"io"
56
"log"
67
"net"
@@ -39,7 +40,7 @@ func (c *RepeaterClientBase) Recv() (http2.Frame, error) {
3940
return c.Client.ReadFrame()
4041
}
4142

42-
func (c *RepeaterClientBase) StartRecvToDevNull2() {
43+
func (c *RepeaterClientBase) StartRecvToDevNull() {
4344
go func() {
4445
buf := make([]byte, 4000000) // Standard buffer size for socket reads
4546
for {
@@ -59,14 +60,19 @@ func (c *RepeaterClientBase) StartRecvToDevNull2() {
5960
}()
6061
}
6162

62-
func (c *RepeaterClientBase) StartRecvToDevNull() {
63+
func (c *RepeaterClientBase) StartRecvToDevNull2() {
6364
go func() {
64-
if tc, ok := c.Client.conn.(*net.TCPConn); ok {
65+
if tc, err := GetTCPConn(c.Client.conn); err == nil {
6566
err := tc.SetReadBuffer(1 << 27) // Ask the OS for 128MB recv buffer so that the TCP window won't block
6667
if err != nil {
6768
log.Println("Error setting read buffer:", err)
6869
}
69-
_, _ = io.Copy(io.Discard, tc)
70+
}
71+
switch conn := c.Client.conn.(type) {
72+
case *net.TCPConn:
73+
_, _ = io.Copy(io.Discard, conn)
74+
case *tls.Conn:
75+
//c.StartRecvToDevNullTLS()
7076
}
7177
}()
7278
}

0 commit comments

Comments
 (0)