add handshake message logging

This commit is contained in:
Lucas Clemente
2016-05-08 22:09:02 +02:00
parent 933b57bc42
commit c6fb85be22
2 changed files with 20 additions and 0 deletions

View File

@@ -73,6 +73,8 @@ func (h *CryptoSetup) HandleCryptoStream() error {
}
chloData := cachingReader.Get()
utils.Infof("Got crypto message:\n%s", printHandshakeMessage(cryptoData))
var reply []byte
if !h.isInchoateCHLO(cryptoData) {
// We have a CHLO with a proper server config ID, do a 0-RTT handshake

View File

@@ -4,6 +4,7 @@ import (
"bytes"
"encoding/binary"
"errors"
"fmt"
"io"
"sort"
@@ -86,3 +87,20 @@ func WriteHandshakeMessage(b *bytes.Buffer, messageTag Tag, data map[Tag][]byte)
// Now we write the index data for real
copy(b.Bytes()[indexStart:], indexData)
}
func printHandshakeMessage(data map[Tag][]byte) string {
var res string
for k, v := range data {
if k == TagPAD {
continue
}
res += fmt.Sprintf("\t%s: %#v\n", tagToString(k), string(v))
}
return res
}
func tagToString(tag Tag) string {
b := make([]byte, 4)
binary.LittleEndian.PutUint32(b, uint32(tag))
return string(b)
}