mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-09-01 09:34:02 +03:00
Success path for fake tls is implemented
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package tlstypes
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
"github.com/9seconds/mtg/utils"
|
||||
)
|
||||
|
||||
type Handshake struct {
|
||||
Type HandshakeType
|
||||
Version Version
|
||||
Random [32]byte
|
||||
SessionID []byte
|
||||
Tail Byter
|
||||
}
|
||||
|
||||
func (h *Handshake) Bytes() []byte {
|
||||
buf := bytes.Buffer{}
|
||||
packetBuf := bytes.Buffer{}
|
||||
|
||||
buf.WriteByte(byte(h.Type))
|
||||
|
||||
packetBuf.Write(h.Version.Bytes())
|
||||
packetBuf.Write(h.Random[:])
|
||||
packetBuf.WriteByte(byte(len(h.SessionID)))
|
||||
packetBuf.Write(h.SessionID)
|
||||
packetBuf.Write(h.Tail.Bytes())
|
||||
|
||||
sizeUint24 := utils.ToUint24(uint32(packetBuf.Len()))
|
||||
sizeUint24Bytes := sizeUint24[:]
|
||||
sizeUint24Bytes[0], sizeUint24Bytes[2] = sizeUint24Bytes[2], sizeUint24Bytes[0]
|
||||
|
||||
buf.Write(sizeUint24Bytes)
|
||||
packetBuf.WriteTo(&buf) // nolint: errcheck
|
||||
|
||||
return buf.Bytes()
|
||||
}
|
||||
Reference in New Issue
Block a user