This repository was archived by the owner on Aug 19, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -66,18 +66,23 @@ func (c *teeConn) Read(b []byte) (int, error) {
6666}
6767
6868type wrappedConn struct {
69+ // Before reading the first handshake message, this is a *teeConn.
70+ // After reading the first handshake message, we switch it to the rawConn.
6971 net.Conn
7072
73+ rawConn net.Conn
7174 hasReadFirstMessage bool
72- raw bytes.Buffer // contains a copy of every byte of the first handshake message we read from the wire
75+ raw * bytes.Buffer // contains a copy of every byte of the first handshake message we read from the wire
7376
7477 hand bytes.Buffer // used to store the first handshake message until we've completely read it
75-
7678}
7779
7880func newWrappedConn (c net.Conn ) net.Conn {
79- wc := & wrappedConn {}
80- wc .Conn = newTeeConn (c , & wc .raw )
81+ wc := & wrappedConn {
82+ raw : & bytes.Buffer {},
83+ rawConn : c ,
84+ }
85+ wc .Conn = newTeeConn (c , wc .raw )
8186 return wc
8287}
8388
@@ -92,6 +97,8 @@ func (c *wrappedConn) Read(b []byte) (int, error) {
9297 if c .raw .Len () > 0 {
9398 n , err := c .raw .Read (b )
9499 if err == io .EOF || c .raw .Len () == 0 {
100+ c .raw = nil
101+ c .Conn = c .rawConn
95102 c .hasReadFirstMessage = true
96103 err = nil
97104 }
You can’t perform that action at this time.
0 commit comments