Fix nil pointer with ClientInfo

This commit is contained in:
Andy Wang 2019-08-14 11:48:32 +01:00
parent 83fb53f0d4
commit 52fac535e3
2 changed files with 3 additions and 3 deletions

View File

@ -218,7 +218,7 @@ var ErrBadClientHello = errors.New("non (or malformed) ClientHello")
var ErrNotCloak = errors.New("TLS but non-Cloak ClientHello") var ErrNotCloak = errors.New("TLS but non-Cloak ClientHello")
var ErrBadProxyMethod = errors.New("invalid proxy method") var ErrBadProxyMethod = errors.New("invalid proxy method")
func PrepareConnection(firstPacket []byte, sta *State, conn net.Conn) (info *ClientInfo, finisher func([]byte) error, err error) { func PrepareConnection(firstPacket []byte, sta *State, conn net.Conn) (info ClientInfo, finisher func([]byte) error, err error) {
ch, err := parseClientHello(firstPacket) ch, err := parseClientHello(firstPacket)
if err != nil { if err != nil {
log.Debug(err) log.Debug(err)

View File

@ -22,7 +22,7 @@ var ErrInvalidPubKey = errors.New("public key has invalid format")
var ErrCiphertextLength = errors.New("ciphertext has the wrong length") var ErrCiphertextLength = errors.New("ciphertext has the wrong length")
var ErrTimestampOutOfWindow = errors.New("timestamp is outside of the accepting window") var ErrTimestampOutOfWindow = errors.New("timestamp is outside of the accepting window")
func TouchStone(ch *ClientHello, sta *State) (info *ClientInfo, sharedSecret []byte, err error) { func TouchStone(ch *ClientHello, sta *State) (info ClientInfo, sharedSecret []byte, err error) {
if sta.registerRandom(ch.random) { if sta.registerRandom(ch.random) {
err = ErrReplay err = ErrReplay
@ -54,7 +54,7 @@ func TouchStone(ch *ClientHello, sta *State) (info *ClientInfo, sharedSecret []b
return return
} }
info = &ClientInfo{ info = ClientInfo{
UID: plaintext[0:16], UID: plaintext[0:16],
SessionId: 0, SessionId: 0,
ProxyMethod: string(bytes.Trim(plaintext[16:28], "\x00")), ProxyMethod: string(bytes.Trim(plaintext[16:28], "\x00")),