Fix: simple-obfs tls

This commit is contained in:
gVisor bot 2018-11-07 16:57:21 +08:00
parent a48a3999e0
commit 27955312a2

View file

@ -107,9 +107,8 @@ func NewTLSObfs(conn net.Conn, server string) net.Conn {
} }
func makeClientHelloMsg(data []byte, server string) []byte { func makeClientHelloMsg(data []byte, server string) []byte {
random := make([]byte, 32) random := make([]byte, 28)
sessionID := make([]byte, 32) sessionID := make([]byte, 32)
size := make([]byte, 2)
rand.Read(random) rand.Read(random)
rand.Read(sessionID) rand.Read(sessionID)
@ -124,12 +123,12 @@ func makeClientHelloMsg(data []byte, server string) []byte {
// clientHello, length, TLS 1.2 version // clientHello, length, TLS 1.2 version
buf.WriteByte(1) buf.WriteByte(1)
binary.BigEndian.PutUint16(size, uint16(208+len(data)+len(server)))
buf.WriteByte(0) buf.WriteByte(0)
buf.Write(size) binary.Write(buf, binary.BigEndian, uint16(208+len(data)+len(server)))
buf.Write([]byte{0x03, 0x03}) buf.Write([]byte{0x03, 0x03})
// random, sid len, sid // random with timestamp, sid len, sid
binary.Write(buf, binary.BigEndian, uint32(time.Now().Unix()))
buf.Write(random) buf.Write(random)
buf.WriteByte(32) buf.WriteByte(32)
buf.Write(sessionID) buf.Write(sessionID)
@ -147,24 +146,19 @@ func makeClientHelloMsg(data []byte, server string) []byte {
buf.Write([]byte{0x01, 0x00}) buf.Write([]byte{0x01, 0x00})
// extension length // extension length
binary.BigEndian.PutUint16(size, uint16(79+len(data)+len(server))) binary.Write(buf, binary.BigEndian, uint16(79+len(data)+len(server)))
buf.Write(size)
// session ticket // session ticket
buf.Write([]byte{0x00, 0x23}) buf.Write([]byte{0x00, 0x23})
binary.BigEndian.PutUint16(size, uint16(len(data))) binary.Write(buf, binary.BigEndian, uint16(len(data)))
buf.Write(size)
buf.Write(data) buf.Write(data)
// server name // server name
buf.Write([]byte{0x00, 0x00}) buf.Write([]byte{0x00, 0x00})
binary.BigEndian.PutUint16(size, uint16(len(server)+5)) binary.Write(buf, binary.BigEndian, uint16(len(server)+5))
buf.Write(size) binary.Write(buf, binary.BigEndian, uint16(len(server)+3))
binary.BigEndian.PutUint16(size, uint16(len(server)+3))
buf.Write(size)
buf.WriteByte(0) buf.WriteByte(0)
binary.BigEndian.PutUint16(size, uint16(len(server))) binary.Write(buf, binary.BigEndian, uint16(len(server)))
buf.Write(size)
buf.Write([]byte(server)) buf.Write([]byte(server))
// ec_point // ec_point