|
|
@@ -1,6 +1,7 @@
|
|
1
|
1
|
package tlstypes
|
|
2
|
2
|
|
|
3
|
3
|
import (
|
|
|
4
|
+ "bytes"
|
|
4
|
5
|
"io"
|
|
5
|
6
|
|
|
6
|
7
|
"github.com/9seconds/mtg/utils"
|
|
|
@@ -15,8 +16,7 @@ type Handshake struct {
|
|
15
|
16
|
}
|
|
16
|
17
|
|
|
17
|
18
|
func (h *Handshake) WriteBytes(writer io.Writer) {
|
|
18
|
|
- packetBuf := acquireBytesBuffer()
|
|
19
|
|
- defer releaseBytesBuffer(packetBuf)
|
|
|
19
|
+ packetBuf := bytes.Buffer{}
|
|
20
|
20
|
|
|
21
|
21
|
writer.Write([]byte{byte(h.Type)}) // nolint: errcheck
|
|
22
|
22
|
|
|
|
@@ -24,7 +24,7 @@ func (h *Handshake) WriteBytes(writer io.Writer) {
|
|
24
|
24
|
packetBuf.Write(h.Random[:])
|
|
25
|
25
|
packetBuf.WriteByte(byte(len(h.SessionID)))
|
|
26
|
26
|
packetBuf.Write(h.SessionID)
|
|
27
|
|
- h.Tail.WriteBytes(packetBuf)
|
|
|
27
|
+ h.Tail.WriteBytes(&packetBuf)
|
|
28
|
28
|
|
|
29
|
29
|
sizeUint24 := utils.ToUint24(uint32(packetBuf.Len()))
|
|
30
|
30
|
sizeUint24Bytes := sizeUint24[:]
|
|
|
@@ -35,10 +35,9 @@ func (h *Handshake) WriteBytes(writer io.Writer) {
|
|
35
|
35
|
}
|
|
36
|
36
|
|
|
37
|
37
|
func (h *Handshake) Len() int {
|
|
38
|
|
- buf := acquireBytesBuffer()
|
|
39
|
|
- defer releaseBytesBuffer(buf)
|
|
|
38
|
+ buf := bytes.Buffer{}
|
|
40
|
39
|
|
|
41
|
|
- h.WriteBytes(buf)
|
|
|
40
|
+ h.WriteBytes(&buf)
|
|
42
|
41
|
|
|
43
|
42
|
return buf.Len()
|
|
44
|
43
|
}
|