File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -62,7 +62,15 @@ func (p *TCPProxy) Handle(conn net.Conn) {
62
62
// See: https://www.ibm.com/docs/en/ztpf/1.1.0.15?topic=sessions-ssl-record-format
63
63
data := make ([]byte , 16384 )
64
64
65
- length , err := conn .Read (data )
65
+ // read the tls header first
66
+ _ , err := io .ReadFull (conn , data [:parser .TLSHeaderLength ])
67
+ if err != nil {
68
+ klog .V (4 ).ErrorS (err , "Error reading TLS header from the connection" )
69
+ return
70
+ }
71
+ // get the total data length then read the rest
72
+ length := int (data [3 ])<< 8 + int (data [4 ]) + parser .TLSHeaderLength
73
+ _ , err = io .ReadFull (conn , data [parser .TLSHeaderLength :length ])
66
74
if err != nil {
67
75
klog .V (4 ).ErrorS (err , "Error reading data from the connection" )
68
76
return
@@ -115,7 +123,7 @@ func (p *TCPProxy) Handle(conn net.Conn) {
115
123
} else {
116
124
_ , err = clientConn .Write (data [:length ])
117
125
if err != nil {
118
- klog .Errorf ("Error writing the first 4k of proxy data: %v" , err )
126
+ klog .Errorf ("Error writing the first %d bytes of proxy data: %v" , length , err )
119
127
clientConn .Close ()
120
128
}
121
129
}
You can’t perform that action at this time.
0 commit comments