handle gQUIC and IETF QUIC packets separately in the client

This commit is contained in:
Marten Seemann 2018-05-07 13:24:43 +09:00
parent b93827ca60
commit 683b5823e4
4 changed files with 61 additions and 35 deletions

View file

@ -10,6 +10,8 @@ import (
// Header is the header of a QUIC packet.
// It contains fields that are only needed for the gQUIC Public Header and the IETF draft Header.
type Header struct {
IsPublicHeader bool
Raw []byte
Version protocol.VersionNumber
@ -34,9 +36,6 @@ type Header struct {
IsLongHeader bool
KeyPhase int
PayloadLen protocol.ByteCount
// only needed for logging
isPublicHeader bool
}
// ParseHeaderSentByServer parses the header for a packet that was sent by the server.
@ -85,7 +84,7 @@ func parsePacketHeader(b *bytes.Reader, sentBy protocol.Perspective, isPublicHea
if err != nil {
return nil, err
}
hdr.isPublicHeader = true // save that this is a Public Header, so we can log it correctly later
hdr.IsPublicHeader = true // save that this is a Public Header, so we can log it correctly later
return hdr, nil
}
return parseHeader(b, sentBy)
@ -94,7 +93,7 @@ func parsePacketHeader(b *bytes.Reader, sentBy protocol.Perspective, isPublicHea
// Write writes the Header.
func (h *Header) Write(b *bytes.Buffer, pers protocol.Perspective, version protocol.VersionNumber) error {
if !version.UsesTLS() {
h.isPublicHeader = true // save that this is a Public Header, so we can log it correctly later
h.IsPublicHeader = true // save that this is a Public Header, so we can log it correctly later
return h.writePublicHeader(b, pers, version)
}
return h.writeHeader(b)
@ -110,7 +109,7 @@ func (h *Header) GetLength(pers protocol.Perspective, version protocol.VersionNu
// Log logs the Header
func (h *Header) Log(logger utils.Logger) {
if h.isPublicHeader {
if h.IsPublicHeader {
h.logPublicHeader(logger)
} else {
h.logHeader(logger)