mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-04 12:47:36 +03:00
split the qlog package into a logging and a qlog package
This commit is contained in:
parent
7c42d7941a
commit
78ba619a0b
25 changed files with 525 additions and 460 deletions
|
@ -11,6 +11,7 @@ import (
|
||||||
|
|
||||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||||
"github.com/lucas-clemente/quic-go/internal/utils"
|
"github.com/lucas-clemente/quic-go/internal/utils"
|
||||||
|
"github.com/lucas-clemente/quic-go/logging"
|
||||||
"github.com/lucas-clemente/quic-go/qlog"
|
"github.com/lucas-clemente/quic-go/qlog"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -40,7 +41,7 @@ type client struct {
|
||||||
|
|
||||||
session quicSession
|
session quicSession
|
||||||
|
|
||||||
qlogger qlog.Tracer
|
qlogger logging.Tracer
|
||||||
logger utils.Logger
|
logger utils.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/lucas-clemente/quic-go/qlog"
|
"github.com/lucas-clemente/quic-go/logging"
|
||||||
|
|
||||||
"github.com/golang/mock/gomock"
|
"github.com/golang/mock/gomock"
|
||||||
"github.com/lucas-clemente/quic-go/internal/mocks"
|
"github.com/lucas-clemente/quic-go/internal/mocks"
|
||||||
|
@ -48,11 +48,11 @@ var _ = Describe("Client", func() {
|
||||||
initialVersion protocol.VersionNumber,
|
initialVersion protocol.VersionNumber,
|
||||||
enable0RTT bool,
|
enable0RTT bool,
|
||||||
hasNegotiatedVersion bool,
|
hasNegotiatedVersion bool,
|
||||||
qlogger qlog.Tracer,
|
qlogger logging.Tracer,
|
||||||
logger utils.Logger,
|
logger utils.Logger,
|
||||||
v protocol.VersionNumber,
|
v protocol.VersionNumber,
|
||||||
) quicSession
|
) quicSession
|
||||||
originalQlogConstructor func(io.WriteCloser, protocol.Perspective, protocol.ConnectionID) qlog.Tracer
|
originalQlogConstructor func(io.WriteCloser, protocol.Perspective, protocol.ConnectionID) logging.Tracer
|
||||||
)
|
)
|
||||||
|
|
||||||
// generate a packet sent by the server that accepts the QUIC version suggested by the client
|
// generate a packet sent by the server that accepts the QUIC version suggested by the client
|
||||||
|
@ -72,7 +72,7 @@ var _ = Describe("Client", func() {
|
||||||
originalClientSessConstructor = newClientSession
|
originalClientSessConstructor = newClientSession
|
||||||
originalQlogConstructor = newQlogger
|
originalQlogConstructor = newQlogger
|
||||||
qlogger = mocks.NewMockTracer(mockCtrl)
|
qlogger = mocks.NewMockTracer(mockCtrl)
|
||||||
newQlogger = func(io.WriteCloser, protocol.Perspective, protocol.ConnectionID) qlog.Tracer {
|
newQlogger = func(io.WriteCloser, protocol.Perspective, protocol.ConnectionID) logging.Tracer {
|
||||||
return qlogger
|
return qlogger
|
||||||
}
|
}
|
||||||
config = &Config{
|
config = &Config{
|
||||||
|
@ -161,7 +161,7 @@ var _ = Describe("Client", func() {
|
||||||
_ protocol.VersionNumber,
|
_ protocol.VersionNumber,
|
||||||
_ bool,
|
_ bool,
|
||||||
_ bool,
|
_ bool,
|
||||||
_ qlog.Tracer,
|
_ logging.Tracer,
|
||||||
_ utils.Logger,
|
_ utils.Logger,
|
||||||
_ protocol.VersionNumber,
|
_ protocol.VersionNumber,
|
||||||
) quicSession {
|
) quicSession {
|
||||||
|
@ -194,7 +194,7 @@ var _ = Describe("Client", func() {
|
||||||
_ protocol.VersionNumber,
|
_ protocol.VersionNumber,
|
||||||
_ bool,
|
_ bool,
|
||||||
_ bool,
|
_ bool,
|
||||||
_ qlog.Tracer,
|
_ logging.Tracer,
|
||||||
_ utils.Logger,
|
_ utils.Logger,
|
||||||
_ protocol.VersionNumber,
|
_ protocol.VersionNumber,
|
||||||
) quicSession {
|
) quicSession {
|
||||||
|
@ -227,7 +227,7 @@ var _ = Describe("Client", func() {
|
||||||
_ protocol.VersionNumber,
|
_ protocol.VersionNumber,
|
||||||
_ bool,
|
_ bool,
|
||||||
_ bool,
|
_ bool,
|
||||||
_ qlog.Tracer,
|
_ logging.Tracer,
|
||||||
_ utils.Logger,
|
_ utils.Logger,
|
||||||
_ protocol.VersionNumber,
|
_ protocol.VersionNumber,
|
||||||
) quicSession {
|
) quicSession {
|
||||||
|
@ -266,7 +266,7 @@ var _ = Describe("Client", func() {
|
||||||
_ protocol.VersionNumber,
|
_ protocol.VersionNumber,
|
||||||
enable0RTT bool,
|
enable0RTT bool,
|
||||||
_ bool,
|
_ bool,
|
||||||
_ qlog.Tracer,
|
_ logging.Tracer,
|
||||||
_ utils.Logger,
|
_ utils.Logger,
|
||||||
_ protocol.VersionNumber,
|
_ protocol.VersionNumber,
|
||||||
) quicSession {
|
) quicSession {
|
||||||
|
@ -309,7 +309,7 @@ var _ = Describe("Client", func() {
|
||||||
_ protocol.VersionNumber,
|
_ protocol.VersionNumber,
|
||||||
enable0RTT bool,
|
enable0RTT bool,
|
||||||
_ bool,
|
_ bool,
|
||||||
_ qlog.Tracer,
|
_ logging.Tracer,
|
||||||
_ utils.Logger,
|
_ utils.Logger,
|
||||||
_ protocol.VersionNumber,
|
_ protocol.VersionNumber,
|
||||||
) quicSession {
|
) quicSession {
|
||||||
|
@ -357,7 +357,7 @@ var _ = Describe("Client", func() {
|
||||||
_ protocol.VersionNumber,
|
_ protocol.VersionNumber,
|
||||||
_ bool,
|
_ bool,
|
||||||
_ bool,
|
_ bool,
|
||||||
_ qlog.Tracer,
|
_ logging.Tracer,
|
||||||
_ utils.Logger,
|
_ utils.Logger,
|
||||||
_ protocol.VersionNumber,
|
_ protocol.VersionNumber,
|
||||||
) quicSession {
|
) quicSession {
|
||||||
|
@ -401,7 +401,7 @@ var _ = Describe("Client", func() {
|
||||||
_ protocol.VersionNumber,
|
_ protocol.VersionNumber,
|
||||||
_ bool,
|
_ bool,
|
||||||
_ bool,
|
_ bool,
|
||||||
_ qlog.Tracer,
|
_ logging.Tracer,
|
||||||
_ utils.Logger,
|
_ utils.Logger,
|
||||||
_ protocol.VersionNumber,
|
_ protocol.VersionNumber,
|
||||||
) quicSession {
|
) quicSession {
|
||||||
|
@ -453,7 +453,7 @@ var _ = Describe("Client", func() {
|
||||||
_ protocol.VersionNumber,
|
_ protocol.VersionNumber,
|
||||||
_ bool,
|
_ bool,
|
||||||
_ bool,
|
_ bool,
|
||||||
_ qlog.Tracer,
|
_ logging.Tracer,
|
||||||
_ utils.Logger,
|
_ utils.Logger,
|
||||||
_ protocol.VersionNumber,
|
_ protocol.VersionNumber,
|
||||||
) quicSession {
|
) quicSession {
|
||||||
|
@ -574,7 +574,7 @@ var _ = Describe("Client", func() {
|
||||||
_ protocol.VersionNumber, /* initial version */
|
_ protocol.VersionNumber, /* initial version */
|
||||||
_ bool,
|
_ bool,
|
||||||
_ bool,
|
_ bool,
|
||||||
_ qlog.Tracer,
|
_ logging.Tracer,
|
||||||
_ utils.Logger,
|
_ utils.Logger,
|
||||||
versionP protocol.VersionNumber,
|
versionP protocol.VersionNumber,
|
||||||
) quicSession {
|
) quicSession {
|
||||||
|
@ -616,7 +616,7 @@ var _ = Describe("Client", func() {
|
||||||
version protocol.VersionNumber,
|
version protocol.VersionNumber,
|
||||||
_ bool,
|
_ bool,
|
||||||
hasNegotiatedVersion bool,
|
hasNegotiatedVersion bool,
|
||||||
_ qlog.Tracer,
|
_ logging.Tracer,
|
||||||
_ utils.Logger,
|
_ utils.Logger,
|
||||||
versionP protocol.VersionNumber,
|
versionP protocol.VersionNumber,
|
||||||
) quicSession {
|
) quicSession {
|
||||||
|
|
|
@ -4,16 +4,17 @@ import (
|
||||||
"github.com/lucas-clemente/quic-go/internal/congestion"
|
"github.com/lucas-clemente/quic-go/internal/congestion"
|
||||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||||
"github.com/lucas-clemente/quic-go/internal/utils"
|
"github.com/lucas-clemente/quic-go/internal/utils"
|
||||||
"github.com/lucas-clemente/quic-go/qlog"
|
"github.com/lucas-clemente/quic-go/logging"
|
||||||
"github.com/lucas-clemente/quic-go/quictrace"
|
"github.com/lucas-clemente/quic-go/quictrace"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// NewAckHandler creates a new SentPacketHandler and a new ReceivedPacketHandler
|
||||||
func NewAckHandler(
|
func NewAckHandler(
|
||||||
initialPacketNumber protocol.PacketNumber,
|
initialPacketNumber protocol.PacketNumber,
|
||||||
rttStats *congestion.RTTStats,
|
rttStats *congestion.RTTStats,
|
||||||
pers protocol.Perspective,
|
pers protocol.Perspective,
|
||||||
traceCallback func(quictrace.Event),
|
traceCallback func(quictrace.Event),
|
||||||
qlogger qlog.Tracer,
|
qlogger logging.Tracer,
|
||||||
logger utils.Logger,
|
logger utils.Logger,
|
||||||
version protocol.VersionNumber,
|
version protocol.VersionNumber,
|
||||||
) (SentPacketHandler, ReceivedPacketHandler) {
|
) (SentPacketHandler, ReceivedPacketHandler) {
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"github.com/lucas-clemente/quic-go/internal/qerr"
|
"github.com/lucas-clemente/quic-go/internal/qerr"
|
||||||
"github.com/lucas-clemente/quic-go/internal/utils"
|
"github.com/lucas-clemente/quic-go/internal/utils"
|
||||||
"github.com/lucas-clemente/quic-go/internal/wire"
|
"github.com/lucas-clemente/quic-go/internal/wire"
|
||||||
"github.com/lucas-clemente/quic-go/qlog"
|
"github.com/lucas-clemente/quic-go/logging"
|
||||||
"github.com/lucas-clemente/quic-go/quictrace"
|
"github.com/lucas-clemente/quic-go/quictrace"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ type sentPacketHandler struct {
|
||||||
perspective protocol.Perspective
|
perspective protocol.Perspective
|
||||||
|
|
||||||
traceCallback func(quictrace.Event)
|
traceCallback func(quictrace.Event)
|
||||||
qlogger qlog.Tracer
|
qlogger logging.Tracer
|
||||||
logger utils.Logger
|
logger utils.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ func newSentPacketHandler(
|
||||||
rttStats *congestion.RTTStats,
|
rttStats *congestion.RTTStats,
|
||||||
pers protocol.Perspective,
|
pers protocol.Perspective,
|
||||||
traceCallback func(quictrace.Event),
|
traceCallback func(quictrace.Event),
|
||||||
qlogger qlog.Tracer,
|
qlogger logging.Tracer,
|
||||||
logger utils.Logger,
|
logger utils.Logger,
|
||||||
) *sentPacketHandler {
|
) *sentPacketHandler {
|
||||||
congestion := congestion.NewCubicSender(
|
congestion := congestion.NewCubicSender(
|
||||||
|
@ -477,7 +477,7 @@ func (h *sentPacketHandler) setLossDetectionTimer() {
|
||||||
// Early retransmit timer or time loss detection.
|
// Early retransmit timer or time loss detection.
|
||||||
h.alarm = lossTime
|
h.alarm = lossTime
|
||||||
if h.qlogger != nil && h.alarm != oldAlarm {
|
if h.qlogger != nil && h.alarm != oldAlarm {
|
||||||
h.qlogger.SetLossTimer(qlog.TimerTypeACK, encLevel, h.alarm)
|
h.qlogger.SetLossTimer(logging.TimerTypeACK, encLevel, h.alarm)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -496,7 +496,7 @@ func (h *sentPacketHandler) setLossDetectionTimer() {
|
||||||
ptoTime, encLevel := h.getPTOTimeAndSpace()
|
ptoTime, encLevel := h.getPTOTimeAndSpace()
|
||||||
h.alarm = ptoTime
|
h.alarm = ptoTime
|
||||||
if h.qlogger != nil && h.alarm != oldAlarm {
|
if h.qlogger != nil && h.alarm != oldAlarm {
|
||||||
h.qlogger.SetLossTimer(qlog.TimerTypePTO, encLevel, h.alarm)
|
h.qlogger.SetLossTimer(logging.TimerTypePTO, encLevel, h.alarm)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -522,12 +522,12 @@ func (h *sentPacketHandler) detectAndRemoveLostPackets(now time.Time, encLevel p
|
||||||
if packet.SendTime.Before(lostSendTime) {
|
if packet.SendTime.Before(lostSendTime) {
|
||||||
lostPackets = append(lostPackets, packet)
|
lostPackets = append(lostPackets, packet)
|
||||||
if h.qlogger != nil {
|
if h.qlogger != nil {
|
||||||
h.qlogger.LostPacket(packet.EncryptionLevel, packet.PacketNumber, qlog.PacketLossTimeThreshold)
|
h.qlogger.LostPacket(packet.EncryptionLevel, packet.PacketNumber, logging.PacketLossTimeThreshold)
|
||||||
}
|
}
|
||||||
} else if pnSpace.largestAcked >= packet.PacketNumber+packetThreshold {
|
} else if pnSpace.largestAcked >= packet.PacketNumber+packetThreshold {
|
||||||
lostPackets = append(lostPackets, packet)
|
lostPackets = append(lostPackets, packet)
|
||||||
if h.qlogger != nil {
|
if h.qlogger != nil {
|
||||||
h.qlogger.LostPacket(packet.EncryptionLevel, packet.PacketNumber, qlog.PacketLossReorderingThreshold)
|
h.qlogger.LostPacket(packet.EncryptionLevel, packet.PacketNumber, logging.PacketLossReorderingThreshold)
|
||||||
}
|
}
|
||||||
} else if pnSpace.lossTime.IsZero() {
|
} else if pnSpace.lossTime.IsZero() {
|
||||||
// Note: This conditional is only entered once per call
|
// Note: This conditional is only entered once per call
|
||||||
|
@ -599,7 +599,7 @@ func (h *sentPacketHandler) onVerifiedLossDetectionTimeout() error {
|
||||||
h.logger.Debugf("Loss detection alarm fired in loss timer mode. Loss time: %s", earliestLossTime)
|
h.logger.Debugf("Loss detection alarm fired in loss timer mode. Loss time: %s", earliestLossTime)
|
||||||
}
|
}
|
||||||
if h.qlogger != nil {
|
if h.qlogger != nil {
|
||||||
h.qlogger.LossTimerExpired(qlog.TimerTypeACK, encLevel)
|
h.qlogger.LossTimerExpired(logging.TimerTypeACK, encLevel)
|
||||||
}
|
}
|
||||||
// Early retransmit or time loss detection
|
// Early retransmit or time loss detection
|
||||||
priorInFlight := h.bytesInFlight
|
priorInFlight := h.bytesInFlight
|
||||||
|
@ -621,7 +621,7 @@ func (h *sentPacketHandler) onVerifiedLossDetectionTimeout() error {
|
||||||
h.logger.Debugf("Loss detection alarm for %s fired in PTO mode. PTO count: %d", encLevel, h.ptoCount)
|
h.logger.Debugf("Loss detection alarm for %s fired in PTO mode. PTO count: %d", encLevel, h.ptoCount)
|
||||||
}
|
}
|
||||||
if h.qlogger != nil {
|
if h.qlogger != nil {
|
||||||
h.qlogger.LossTimerExpired(qlog.TimerTypePTO, encLevel)
|
h.qlogger.LossTimerExpired(logging.TimerTypePTO, encLevel)
|
||||||
h.qlogger.UpdatedPTOCount(h.ptoCount)
|
h.qlogger.UpdatedPTOCount(h.ptoCount)
|
||||||
}
|
}
|
||||||
h.numProbesToSend += 2
|
h.numProbesToSend += 2
|
||||||
|
|
|
@ -15,7 +15,7 @@ import (
|
||||||
"github.com/lucas-clemente/quic-go/internal/qerr"
|
"github.com/lucas-clemente/quic-go/internal/qerr"
|
||||||
"github.com/lucas-clemente/quic-go/internal/utils"
|
"github.com/lucas-clemente/quic-go/internal/utils"
|
||||||
"github.com/lucas-clemente/quic-go/internal/wire"
|
"github.com/lucas-clemente/quic-go/internal/wire"
|
||||||
"github.com/lucas-clemente/quic-go/qlog"
|
"github.com/lucas-clemente/quic-go/logging"
|
||||||
"github.com/marten-seemann/qtls"
|
"github.com/marten-seemann/qtls"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ type cryptoSetup struct {
|
||||||
|
|
||||||
rttStats *congestion.RTTStats
|
rttStats *congestion.RTTStats
|
||||||
|
|
||||||
qlogger qlog.Tracer
|
qlogger logging.Tracer
|
||||||
logger utils.Logger
|
logger utils.Logger
|
||||||
|
|
||||||
perspective protocol.Perspective
|
perspective protocol.Perspective
|
||||||
|
@ -137,7 +137,7 @@ func NewCryptoSetupClient(
|
||||||
tlsConf *tls.Config,
|
tlsConf *tls.Config,
|
||||||
enable0RTT bool,
|
enable0RTT bool,
|
||||||
rttStats *congestion.RTTStats,
|
rttStats *congestion.RTTStats,
|
||||||
qlogger qlog.Tracer,
|
qlogger logging.Tracer,
|
||||||
logger utils.Logger,
|
logger utils.Logger,
|
||||||
) (CryptoSetup, <-chan *wire.TransportParameters /* ClientHello written. Receive nil for non-0-RTT */) {
|
) (CryptoSetup, <-chan *wire.TransportParameters /* ClientHello written. Receive nil for non-0-RTT */) {
|
||||||
cs, clientHelloWritten := newCryptoSetup(
|
cs, clientHelloWritten := newCryptoSetup(
|
||||||
|
@ -169,7 +169,7 @@ func NewCryptoSetupServer(
|
||||||
tlsConf *tls.Config,
|
tlsConf *tls.Config,
|
||||||
enable0RTT bool,
|
enable0RTT bool,
|
||||||
rttStats *congestion.RTTStats,
|
rttStats *congestion.RTTStats,
|
||||||
qlogger qlog.Tracer,
|
qlogger logging.Tracer,
|
||||||
logger utils.Logger,
|
logger utils.Logger,
|
||||||
) CryptoSetup {
|
) CryptoSetup {
|
||||||
cs, _ := newCryptoSetup(
|
cs, _ := newCryptoSetup(
|
||||||
|
@ -198,7 +198,7 @@ func newCryptoSetup(
|
||||||
tlsConf *tls.Config,
|
tlsConf *tls.Config,
|
||||||
enable0RTT bool,
|
enable0RTT bool,
|
||||||
rttStats *congestion.RTTStats,
|
rttStats *congestion.RTTStats,
|
||||||
qlogger qlog.Tracer,
|
qlogger logging.Tracer,
|
||||||
logger utils.Logger,
|
logger utils.Logger,
|
||||||
perspective protocol.Perspective,
|
perspective protocol.Perspective,
|
||||||
) (*cryptoSetup, <-chan *wire.TransportParameters /* ClientHello written. Receive nil for non-0-RTT */) {
|
) (*cryptoSetup, <-chan *wire.TransportParameters /* ClientHello written. Receive nil for non-0-RTT */) {
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
"github.com/lucas-clemente/quic-go/internal/congestion"
|
"github.com/lucas-clemente/quic-go/internal/congestion"
|
||||||
"github.com/lucas-clemente/quic-go/internal/qerr"
|
"github.com/lucas-clemente/quic-go/internal/qerr"
|
||||||
"github.com/lucas-clemente/quic-go/internal/utils"
|
"github.com/lucas-clemente/quic-go/internal/utils"
|
||||||
"github.com/lucas-clemente/quic-go/qlog"
|
"github.com/lucas-clemente/quic-go/logging"
|
||||||
|
|
||||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||||
"github.com/marten-seemann/qtls"
|
"github.com/marten-seemann/qtls"
|
||||||
|
@ -74,7 +74,7 @@ type updatableAEAD struct {
|
||||||
|
|
||||||
rttStats *congestion.RTTStats
|
rttStats *congestion.RTTStats
|
||||||
|
|
||||||
qlogger qlog.Tracer
|
qlogger logging.Tracer
|
||||||
logger utils.Logger
|
logger utils.Logger
|
||||||
|
|
||||||
// use a single slice to avoid allocations
|
// use a single slice to avoid allocations
|
||||||
|
@ -84,7 +84,7 @@ type updatableAEAD struct {
|
||||||
var _ ShortHeaderOpener = &updatableAEAD{}
|
var _ ShortHeaderOpener = &updatableAEAD{}
|
||||||
var _ ShortHeaderSealer = &updatableAEAD{}
|
var _ ShortHeaderSealer = &updatableAEAD{}
|
||||||
|
|
||||||
func newUpdatableAEAD(rttStats *congestion.RTTStats, qlogger qlog.Tracer, logger utils.Logger) *updatableAEAD {
|
func newUpdatableAEAD(rttStats *congestion.RTTStats, qlogger logging.Tracer, logger utils.Logger) *updatableAEAD {
|
||||||
return &updatableAEAD{
|
return &updatableAEAD{
|
||||||
firstPacketNumber: protocol.InvalidPacketNumber,
|
firstPacketNumber: protocol.InvalidPacketNumber,
|
||||||
largestAcked: protocol.InvalidPacketNumber,
|
largestAcked: protocol.InvalidPacketNumber,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Code generated by MockGen. DO NOT EDIT.
|
// Code generated by MockGen. DO NOT EDIT.
|
||||||
// Source: github.com/lucas-clemente/quic-go/qlog (interfaces: Tracer)
|
// Source: github.com/lucas-clemente/quic-go/logging (interfaces: Tracer)
|
||||||
|
|
||||||
// Package mocks is a generated GoMock package.
|
// Package mocks is a generated GoMock package.
|
||||||
package mocks
|
package mocks
|
||||||
|
@ -13,7 +13,7 @@ import (
|
||||||
congestion "github.com/lucas-clemente/quic-go/internal/congestion"
|
congestion "github.com/lucas-clemente/quic-go/internal/congestion"
|
||||||
protocol "github.com/lucas-clemente/quic-go/internal/protocol"
|
protocol "github.com/lucas-clemente/quic-go/internal/protocol"
|
||||||
wire "github.com/lucas-clemente/quic-go/internal/wire"
|
wire "github.com/lucas-clemente/quic-go/internal/wire"
|
||||||
qlog "github.com/lucas-clemente/quic-go/qlog"
|
logging "github.com/lucas-clemente/quic-go/logging"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MockTracer is a mock of Tracer interface
|
// MockTracer is a mock of Tracer interface
|
||||||
|
@ -40,7 +40,7 @@ func (m *MockTracer) EXPECT() *MockTracerMockRecorder {
|
||||||
}
|
}
|
||||||
|
|
||||||
// BufferedPacket mocks base method
|
// BufferedPacket mocks base method
|
||||||
func (m *MockTracer) BufferedPacket(arg0 qlog.PacketType) {
|
func (m *MockTracer) BufferedPacket(arg0 logging.PacketType) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
m.ctrl.Call(m, "BufferedPacket", arg0)
|
m.ctrl.Call(m, "BufferedPacket", arg0)
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ func (mr *MockTracerMockRecorder) BufferedPacket(arg0 interface{}) *gomock.Call
|
||||||
}
|
}
|
||||||
|
|
||||||
// ClosedConnection mocks base method
|
// ClosedConnection mocks base method
|
||||||
func (m *MockTracer) ClosedConnection(arg0 qlog.CloseReason) {
|
func (m *MockTracer) ClosedConnection(arg0 logging.CloseReason) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
m.ctrl.Call(m, "ClosedConnection", arg0)
|
m.ctrl.Call(m, "ClosedConnection", arg0)
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ func (mr *MockTracerMockRecorder) DroppedEncryptionLevel(arg0 interface{}) *gomo
|
||||||
}
|
}
|
||||||
|
|
||||||
// DroppedPacket mocks base method
|
// DroppedPacket mocks base method
|
||||||
func (m *MockTracer) DroppedPacket(arg0 qlog.PacketType, arg1 protocol.ByteCount, arg2 qlog.PacketDropReason) {
|
func (m *MockTracer) DroppedPacket(arg0 logging.PacketType, arg1 protocol.ByteCount, arg2 logging.PacketDropReason) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
m.ctrl.Call(m, "DroppedPacket", arg0, arg1, arg2)
|
m.ctrl.Call(m, "DroppedPacket", arg0, arg1, arg2)
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ func (mr *MockTracerMockRecorder) LossTimerCanceled() *gomock.Call {
|
||||||
}
|
}
|
||||||
|
|
||||||
// LossTimerExpired mocks base method
|
// LossTimerExpired mocks base method
|
||||||
func (m *MockTracer) LossTimerExpired(arg0 qlog.TimerType, arg1 protocol.EncryptionLevel) {
|
func (m *MockTracer) LossTimerExpired(arg0 logging.TimerType, arg1 protocol.EncryptionLevel) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
m.ctrl.Call(m, "LossTimerExpired", arg0, arg1)
|
m.ctrl.Call(m, "LossTimerExpired", arg0, arg1)
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ func (mr *MockTracerMockRecorder) LossTimerExpired(arg0, arg1 interface{}) *gomo
|
||||||
}
|
}
|
||||||
|
|
||||||
// LostPacket mocks base method
|
// LostPacket mocks base method
|
||||||
func (m *MockTracer) LostPacket(arg0 protocol.EncryptionLevel, arg1 protocol.PacketNumber, arg2 qlog.PacketLossReason) {
|
func (m *MockTracer) LostPacket(arg0 protocol.EncryptionLevel, arg1 protocol.PacketNumber, arg2 logging.PacketLossReason) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
m.ctrl.Call(m, "LostPacket", arg0, arg1, arg2)
|
m.ctrl.Call(m, "LostPacket", arg0, arg1, arg2)
|
||||||
}
|
}
|
||||||
|
@ -222,7 +222,7 @@ func (mr *MockTracerMockRecorder) SentTransportParameters(arg0 interface{}) *gom
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetLossTimer mocks base method
|
// SetLossTimer mocks base method
|
||||||
func (m *MockTracer) SetLossTimer(arg0 qlog.TimerType, arg1 protocol.EncryptionLevel, arg2 time.Time) {
|
func (m *MockTracer) SetLossTimer(arg0 logging.TimerType, arg1 protocol.EncryptionLevel, arg2 time.Time) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
m.ctrl.Call(m, "SetLossTimer", arg0, arg1, arg2)
|
m.ctrl.Call(m, "SetLossTimer", arg0, arg1, arg2)
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@ package mocks
|
||||||
//go:generate sh -c "mockgen -package mockquic -destination quic/stream.go github.com/lucas-clemente/quic-go Stream && goimports -w quic/stream.go"
|
//go:generate sh -c "mockgen -package mockquic -destination quic/stream.go github.com/lucas-clemente/quic-go Stream && goimports -w quic/stream.go"
|
||||||
//go:generate sh -c "mockgen -package mockquic -destination quic/early_session.go github.com/lucas-clemente/quic-go EarlySession && goimports -w quic/early_session.go"
|
//go:generate sh -c "mockgen -package mockquic -destination quic/early_session.go github.com/lucas-clemente/quic-go EarlySession && goimports -w quic/early_session.go"
|
||||||
//go:generate sh -c "mockgen -package mockquic -destination quic/early_listener.go github.com/lucas-clemente/quic-go EarlyListener && goimports -w quic/early_listener.go"
|
//go:generate sh -c "mockgen -package mockquic -destination quic/early_listener.go github.com/lucas-clemente/quic-go EarlyListener && goimports -w quic/early_listener.go"
|
||||||
//go:generate sh -c "mockgen -package mocks -destination qlog.go github.com/lucas-clemente/quic-go/qlog Tracer && goimports -w qlog.go"
|
//go:generate sh -c "mockgen -package mocks -destination logging.go github.com/lucas-clemente/quic-go/logging Tracer && goimports -w logging.go"
|
||||||
//go:generate sh -c "mockgen -package mocks -destination short_header_sealer.go github.com/lucas-clemente/quic-go/internal/handshake ShortHeaderSealer && goimports -w short_header_sealer.go"
|
//go:generate sh -c "mockgen -package mocks -destination short_header_sealer.go github.com/lucas-clemente/quic-go/internal/handshake ShortHeaderSealer && goimports -w short_header_sealer.go"
|
||||||
//go:generate sh -c "mockgen -package mocks -destination short_header_opener.go github.com/lucas-clemente/quic-go/internal/handshake ShortHeaderOpener && goimports -w short_header_opener.go"
|
//go:generate sh -c "mockgen -package mocks -destination short_header_opener.go github.com/lucas-clemente/quic-go/internal/handshake ShortHeaderOpener && goimports -w short_header_opener.go"
|
||||||
//go:generate sh -c "mockgen -package mocks -destination long_header_opener.go github.com/lucas-clemente/quic-go/internal/handshake LongHeaderOpener && goimports -w long_header_opener.go"
|
//go:generate sh -c "mockgen -package mocks -destination long_header_opener.go github.com/lucas-clemente/quic-go/internal/handshake LongHeaderOpener && goimports -w long_header_opener.go"
|
||||||
|
|
37
logging/interface.go
Normal file
37
logging/interface.go
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
// Package logging defines a logging interface for quic-go.
|
||||||
|
// This package should not be considered stable
|
||||||
|
package logging
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/lucas-clemente/quic-go/internal/congestion"
|
||||||
|
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||||
|
"github.com/lucas-clemente/quic-go/internal/wire"
|
||||||
|
)
|
||||||
|
|
||||||
|
// A Tracer records events.
|
||||||
|
type Tracer interface {
|
||||||
|
Export() error
|
||||||
|
StartedConnection(local, remote net.Addr, version protocol.VersionNumber, srcConnID, destConnID protocol.ConnectionID)
|
||||||
|
ClosedConnection(CloseReason)
|
||||||
|
SentTransportParameters(*wire.TransportParameters)
|
||||||
|
ReceivedTransportParameters(*wire.TransportParameters)
|
||||||
|
SentPacket(hdr *wire.ExtendedHeader, packetSize protocol.ByteCount, ack *wire.AckFrame, frames []wire.Frame)
|
||||||
|
ReceivedVersionNegotiationPacket(*wire.Header)
|
||||||
|
ReceivedRetry(*wire.Header)
|
||||||
|
ReceivedPacket(hdr *wire.ExtendedHeader, packetSize protocol.ByteCount, frames []wire.Frame)
|
||||||
|
ReceivedStatelessReset(token *[16]byte)
|
||||||
|
BufferedPacket(PacketType)
|
||||||
|
DroppedPacket(PacketType, protocol.ByteCount, PacketDropReason)
|
||||||
|
UpdatedMetrics(rttStats *congestion.RTTStats, cwnd protocol.ByteCount, bytesInFLight protocol.ByteCount, packetsInFlight int)
|
||||||
|
LostPacket(protocol.EncryptionLevel, protocol.PacketNumber, PacketLossReason)
|
||||||
|
UpdatedPTOCount(value uint32)
|
||||||
|
UpdatedKeyFromTLS(protocol.EncryptionLevel, protocol.Perspective)
|
||||||
|
UpdatedKey(generation protocol.KeyPhase, remote bool)
|
||||||
|
DroppedEncryptionLevel(protocol.EncryptionLevel)
|
||||||
|
SetLossTimer(TimerType, protocol.EncryptionLevel, time.Time)
|
||||||
|
LossTimerExpired(TimerType, protocol.EncryptionLevel)
|
||||||
|
LossTimerCanceled()
|
||||||
|
}
|
13
logging/logging_sutie_test.go
Normal file
13
logging/logging_sutie_test.go
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
package logging
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
. "github.com/onsi/ginkgo"
|
||||||
|
. "github.com/onsi/gomega"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestLoggingt(t *testing.T) {
|
||||||
|
RegisterFailHandler(Fail)
|
||||||
|
RunSpecs(t, "Logging Suite")
|
||||||
|
}
|
43
logging/packet_header.go
Normal file
43
logging/packet_header.go
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
package logging
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||||
|
"github.com/lucas-clemente/quic-go/internal/wire"
|
||||||
|
)
|
||||||
|
|
||||||
|
// PacketTypeFromHeader determines the packet type from a *wire.Header.
|
||||||
|
func PacketTypeFromHeader(hdr *wire.Header) PacketType {
|
||||||
|
if !hdr.IsLongHeader {
|
||||||
|
return PacketType1RTT
|
||||||
|
}
|
||||||
|
if hdr.Version == 0 {
|
||||||
|
return PacketTypeVersionNegotiation
|
||||||
|
}
|
||||||
|
switch hdr.Type {
|
||||||
|
case protocol.PacketTypeInitial:
|
||||||
|
return PacketTypeInitial
|
||||||
|
case protocol.PacketTypeHandshake:
|
||||||
|
return PacketTypeHandshake
|
||||||
|
case protocol.PacketType0RTT:
|
||||||
|
return PacketType0RTT
|
||||||
|
case protocol.PacketTypeRetry:
|
||||||
|
return PacketTypeRetry
|
||||||
|
default:
|
||||||
|
return PacketTypeNotDetermined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// PacketHeader is a QUIC packet header.
|
||||||
|
type PacketHeader struct {
|
||||||
|
PacketType PacketType
|
||||||
|
|
||||||
|
PacketNumber protocol.PacketNumber
|
||||||
|
PayloadLength protocol.ByteCount
|
||||||
|
// Size of the QUIC packet (QUIC header + payload).
|
||||||
|
// See https://github.com/quiclog/internet-drafts/issues/40.
|
||||||
|
PacketSize protocol.ByteCount
|
||||||
|
|
||||||
|
Version protocol.VersionNumber
|
||||||
|
SrcConnectionID protocol.ConnectionID
|
||||||
|
DestConnectionID protocol.ConnectionID
|
||||||
|
}
|
60
logging/packet_header_test.go
Normal file
60
logging/packet_header_test.go
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
package logging
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||||
|
"github.com/lucas-clemente/quic-go/internal/wire"
|
||||||
|
|
||||||
|
. "github.com/onsi/ginkgo"
|
||||||
|
. "github.com/onsi/gomega"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ = Describe("Packet Header", func() {
|
||||||
|
Context("determining the packet type from the header", func() {
|
||||||
|
It("recognizes Initial packets", func() {
|
||||||
|
Expect(PacketTypeFromHeader(&wire.Header{
|
||||||
|
IsLongHeader: true,
|
||||||
|
Type: protocol.PacketTypeInitial,
|
||||||
|
Version: protocol.VersionTLS,
|
||||||
|
})).To(Equal(PacketTypeInitial))
|
||||||
|
})
|
||||||
|
|
||||||
|
It("recognizes Handshake packets", func() {
|
||||||
|
Expect(PacketTypeFromHeader(&wire.Header{
|
||||||
|
IsLongHeader: true,
|
||||||
|
Type: protocol.PacketTypeHandshake,
|
||||||
|
Version: protocol.VersionTLS,
|
||||||
|
})).To(Equal(PacketTypeHandshake))
|
||||||
|
})
|
||||||
|
|
||||||
|
It("recognizes Retry packets", func() {
|
||||||
|
Expect(PacketTypeFromHeader(&wire.Header{
|
||||||
|
IsLongHeader: true,
|
||||||
|
Type: protocol.PacketTypeRetry,
|
||||||
|
Version: protocol.VersionTLS,
|
||||||
|
})).To(Equal(PacketTypeRetry))
|
||||||
|
})
|
||||||
|
|
||||||
|
It("recognizes 0-RTT packets", func() {
|
||||||
|
Expect(PacketTypeFromHeader(&wire.Header{
|
||||||
|
IsLongHeader: true,
|
||||||
|
Type: protocol.PacketType0RTT,
|
||||||
|
Version: protocol.VersionTLS,
|
||||||
|
})).To(Equal(PacketType0RTT))
|
||||||
|
})
|
||||||
|
|
||||||
|
It("recognizes Version Negotiation packets", func() {
|
||||||
|
Expect(PacketTypeFromHeader(&wire.Header{IsLongHeader: true})).To(Equal(PacketTypeVersionNegotiation))
|
||||||
|
})
|
||||||
|
|
||||||
|
It("recognizes 1-RTT packets", func() {
|
||||||
|
Expect(PacketTypeFromHeader(&wire.Header{})).To(Equal(PacketType1RTT))
|
||||||
|
})
|
||||||
|
|
||||||
|
It("handles unrecognized packet types", func() {
|
||||||
|
Expect(PacketTypeFromHeader(&wire.Header{
|
||||||
|
IsLongHeader: true,
|
||||||
|
Version: protocol.VersionTLS,
|
||||||
|
})).To(Equal(PacketTypeNotDetermined))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
170
logging/types.go
Normal file
170
logging/types.go
Normal file
|
@ -0,0 +1,170 @@
|
||||||
|
package logging
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||||
|
)
|
||||||
|
|
||||||
|
// PacketType is the packet type of a QUIC packet
|
||||||
|
type PacketType protocol.PacketType
|
||||||
|
|
||||||
|
const (
|
||||||
|
// PacketTypeInitial is the packet type of an Initial packet
|
||||||
|
PacketTypeInitial PacketType = iota
|
||||||
|
// PacketTypeHandshake is the packet type of a Handshake packet
|
||||||
|
PacketTypeHandshake
|
||||||
|
// PacketTypeRetry is the packet type of a Retry packet
|
||||||
|
PacketTypeRetry
|
||||||
|
// PacketType0RTT is the packet type of a 0-RTT packet
|
||||||
|
PacketType0RTT
|
||||||
|
// PacketTypeVersionNegotiation is the packet type of a Version Negotiation packet
|
||||||
|
PacketTypeVersionNegotiation
|
||||||
|
// PacketType1RTT is a 1-RTT packet
|
||||||
|
PacketType1RTT
|
||||||
|
// PacketTypeStatelessReset is a stateless reset
|
||||||
|
PacketTypeStatelessReset
|
||||||
|
// PacketTypeNotDetermined is the packet type when it could not be determined
|
||||||
|
PacketTypeNotDetermined
|
||||||
|
)
|
||||||
|
|
||||||
|
func (t PacketType) String() string {
|
||||||
|
switch t {
|
||||||
|
case PacketTypeInitial:
|
||||||
|
return "initial"
|
||||||
|
case PacketTypeHandshake:
|
||||||
|
return "handshake"
|
||||||
|
case PacketTypeRetry:
|
||||||
|
return "retry"
|
||||||
|
case PacketType0RTT:
|
||||||
|
return "0RTT"
|
||||||
|
case PacketTypeVersionNegotiation:
|
||||||
|
return "version_negotiation"
|
||||||
|
case PacketTypeStatelessReset:
|
||||||
|
return "stateless_reset"
|
||||||
|
case PacketType1RTT:
|
||||||
|
return "1RTT"
|
||||||
|
case PacketTypeNotDetermined:
|
||||||
|
return ""
|
||||||
|
default:
|
||||||
|
panic("unknown packet type")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type PacketLossReason uint8
|
||||||
|
|
||||||
|
const (
|
||||||
|
// PacketLossReorderingThreshold: when a packet is deemed lost due to reordering threshold
|
||||||
|
PacketLossReorderingThreshold PacketLossReason = iota
|
||||||
|
// PacketLossTimeThreshold: when a packet is deemed lost due to time threshold
|
||||||
|
PacketLossTimeThreshold
|
||||||
|
)
|
||||||
|
|
||||||
|
func (r PacketLossReason) String() string {
|
||||||
|
switch r {
|
||||||
|
case PacketLossReorderingThreshold:
|
||||||
|
return "reordering_threshold"
|
||||||
|
case PacketLossTimeThreshold:
|
||||||
|
return "time_threshold"
|
||||||
|
default:
|
||||||
|
panic("unknown loss reason")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type PacketDropReason uint8
|
||||||
|
|
||||||
|
const (
|
||||||
|
// PacketDropKeyUnavailable is used when a packet is dropped because keys are unavailable
|
||||||
|
PacketDropKeyUnavailable PacketDropReason = iota
|
||||||
|
// PacketDropUnknownConnectionID is used when a packet is dropped because the connection ID is unknown
|
||||||
|
PacketDropUnknownConnectionID
|
||||||
|
// PacketDropHeaderParseError is used when a packet is dropped because header parsing failed
|
||||||
|
PacketDropHeaderParseError
|
||||||
|
// PacketDropPayloadDecryptError is used when a packet is dropped because decrypting the payload failed
|
||||||
|
PacketDropPayloadDecryptError
|
||||||
|
// PacketDropProtocolViolation is used when a packet is dropped due to a protocol violation
|
||||||
|
PacketDropProtocolViolation
|
||||||
|
// PacketDropDOSPrevention is used when a packet is dropped to mitigate a DoS attack
|
||||||
|
PacketDropDOSPrevention
|
||||||
|
// PacketDropUnsupportedVersion is used when a packet is dropped because the version is not supported
|
||||||
|
PacketDropUnsupportedVersion
|
||||||
|
// PacketDropUnexpectedPacket is used when an unexpected packet is received
|
||||||
|
PacketDropUnexpectedPacket
|
||||||
|
// PacketDropUnexpectedSourceConnectionID is used when a packet with an unexpected source connection ID is received
|
||||||
|
PacketDropUnexpectedSourceConnectionID
|
||||||
|
// PacketDropUnexpectedVersion is used when a packet with an unexpected version is received
|
||||||
|
PacketDropUnexpectedVersion
|
||||||
|
// PacketDropDuplicate is used when a duplicate packet is received
|
||||||
|
PacketDropDuplicate
|
||||||
|
)
|
||||||
|
|
||||||
|
func (r PacketDropReason) String() string {
|
||||||
|
switch r {
|
||||||
|
case PacketDropKeyUnavailable:
|
||||||
|
return "key_unavailable"
|
||||||
|
case PacketDropUnknownConnectionID:
|
||||||
|
return "unknown_connection_id"
|
||||||
|
case PacketDropHeaderParseError:
|
||||||
|
return "header_parse_error"
|
||||||
|
case PacketDropPayloadDecryptError:
|
||||||
|
return "payload_decrypt_error"
|
||||||
|
case PacketDropProtocolViolation:
|
||||||
|
return "protocol_violation"
|
||||||
|
case PacketDropDOSPrevention:
|
||||||
|
return "dos_prevention"
|
||||||
|
case PacketDropUnsupportedVersion:
|
||||||
|
return "unsupported_version"
|
||||||
|
case PacketDropUnexpectedPacket:
|
||||||
|
return "unexpected_packet"
|
||||||
|
case PacketDropUnexpectedSourceConnectionID:
|
||||||
|
return "unexpected_source_connection_id"
|
||||||
|
case PacketDropUnexpectedVersion:
|
||||||
|
return "unexpected_version"
|
||||||
|
case PacketDropDuplicate:
|
||||||
|
return "duplicate"
|
||||||
|
default:
|
||||||
|
panic("unknown packet drop reason")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TimerType is the type of the loss detection timer
|
||||||
|
type TimerType uint8
|
||||||
|
|
||||||
|
const (
|
||||||
|
// TimerTypeACK is the timer type for the early retransmit timer
|
||||||
|
TimerTypeACK TimerType = iota
|
||||||
|
// TimerTypePTO is the timer type for the PTO retransmit timer
|
||||||
|
TimerTypePTO
|
||||||
|
)
|
||||||
|
|
||||||
|
func (t TimerType) String() string {
|
||||||
|
switch t {
|
||||||
|
case TimerTypeACK:
|
||||||
|
return "ack"
|
||||||
|
case TimerTypePTO:
|
||||||
|
return "pto"
|
||||||
|
default:
|
||||||
|
panic("unknown timer type")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CloseReason is the reason why a session is closed
|
||||||
|
type CloseReason uint8
|
||||||
|
|
||||||
|
const (
|
||||||
|
// CloseReasonHandshakeTimeout is used when the session is closed due to a handshake timeout
|
||||||
|
// This reason is not defined in the qlog draft, but very useful for debugging.
|
||||||
|
CloseReasonHandshakeTimeout CloseReason = iota
|
||||||
|
// CloseReasonIdleTimeout is used when the session is closed due to an idle timeout
|
||||||
|
// This reason is not defined in the qlog draft, but very useful for debugging.
|
||||||
|
CloseReasonIdleTimeout
|
||||||
|
)
|
||||||
|
|
||||||
|
func (r CloseReason) String() string {
|
||||||
|
switch r {
|
||||||
|
case CloseReasonHandshakeTimeout:
|
||||||
|
return "handshake_timeout"
|
||||||
|
case CloseReasonIdleTimeout:
|
||||||
|
return "idle_timeout"
|
||||||
|
default:
|
||||||
|
panic("unknown close reason")
|
||||||
|
}
|
||||||
|
}
|
42
logging/types_test.go
Normal file
42
logging/types_test.go
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
package logging
|
||||||
|
|
||||||
|
import (
|
||||||
|
. "github.com/onsi/ginkgo"
|
||||||
|
. "github.com/onsi/gomega"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ = Describe("Types", func() {
|
||||||
|
It("has a string representation for the packet type", func() {
|
||||||
|
Expect(PacketTypeInitial.String()).To(Equal("initial"))
|
||||||
|
Expect(PacketTypeHandshake.String()).To(Equal("handshake"))
|
||||||
|
Expect(PacketType0RTT.String()).To(Equal("0RTT"))
|
||||||
|
Expect(PacketType1RTT.String()).To(Equal("1RTT"))
|
||||||
|
Expect(PacketTypeStatelessReset.String()).To(Equal("stateless_reset"))
|
||||||
|
Expect(PacketTypeRetry.String()).To(Equal("retry"))
|
||||||
|
Expect(PacketTypeVersionNegotiation.String()).To(Equal("version_negotiation"))
|
||||||
|
Expect(PacketTypeNotDetermined.String()).To(BeEmpty())
|
||||||
|
})
|
||||||
|
|
||||||
|
It("has a string representation for the packet drop reason", func() {
|
||||||
|
Expect(PacketDropKeyUnavailable.String()).To(Equal("key_unavailable"))
|
||||||
|
Expect(PacketDropUnknownConnectionID.String()).To(Equal("unknown_connection_id"))
|
||||||
|
Expect(PacketDropHeaderParseError.String()).To(Equal("header_parse_error"))
|
||||||
|
Expect(PacketDropPayloadDecryptError.String()).To(Equal("payload_decrypt_error"))
|
||||||
|
Expect(PacketDropProtocolViolation.String()).To(Equal("protocol_violation"))
|
||||||
|
Expect(PacketDropDOSPrevention.String()).To(Equal("dos_prevention"))
|
||||||
|
Expect(PacketDropUnsupportedVersion.String()).To(Equal("unsupported_version"))
|
||||||
|
Expect(PacketDropUnexpectedPacket.String()).To(Equal("unexpected_packet"))
|
||||||
|
Expect(PacketDropUnexpectedSourceConnectionID.String()).To(Equal("unexpected_source_connection_id"))
|
||||||
|
Expect(PacketDropUnexpectedVersion.String()).To(Equal("unexpected_version"))
|
||||||
|
})
|
||||||
|
|
||||||
|
It("has a string representation for the timer type", func() {
|
||||||
|
Expect(TimerTypeACK.String()).To(Equal("ack"))
|
||||||
|
Expect(TimerTypePTO.String()).To(Equal("pto"))
|
||||||
|
})
|
||||||
|
|
||||||
|
It("has a string representation for the close reason", func() {
|
||||||
|
Expect(CloseReasonHandshakeTimeout.String()).To(Equal("handshake_timeout"))
|
||||||
|
Expect(CloseReasonIdleTimeout.String()).To(Equal("idle_timeout"))
|
||||||
|
})
|
||||||
|
})
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||||
|
"github.com/lucas-clemente/quic-go/logging"
|
||||||
|
|
||||||
"github.com/francoispqt/gojay"
|
"github.com/francoispqt/gojay"
|
||||||
)
|
)
|
||||||
|
@ -93,7 +94,7 @@ func (e eventConnectionStarted) MarshalJSONObject(enc *gojay.Encoder) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type eventConnectionClosed struct {
|
type eventConnectionClosed struct {
|
||||||
Reason CloseReason
|
Reason logging.CloseReason
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e eventConnectionClosed) Category() category { return categoryTransport }
|
func (e eventConnectionClosed) Category() category { return categoryTransport }
|
||||||
|
@ -106,7 +107,7 @@ func (e eventConnectionClosed) MarshalJSONObject(enc *gojay.Encoder) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type eventPacketSent struct {
|
type eventPacketSent struct {
|
||||||
PacketType PacketType
|
PacketType logging.PacketType
|
||||||
Header packetHeader
|
Header packetHeader
|
||||||
Frames frames
|
Frames frames
|
||||||
IsCoalesced bool
|
IsCoalesced bool
|
||||||
|
@ -128,7 +129,7 @@ func (e eventPacketSent) MarshalJSONObject(enc *gojay.Encoder) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type eventPacketReceived struct {
|
type eventPacketReceived struct {
|
||||||
PacketType PacketType
|
PacketType logging.PacketType
|
||||||
Header packetHeader
|
Header packetHeader
|
||||||
Frames frames
|
Frames frames
|
||||||
IsCoalesced bool
|
IsCoalesced bool
|
||||||
|
@ -158,7 +159,7 @@ func (e eventRetryReceived) Name() string { return "packet_received" }
|
||||||
func (e eventRetryReceived) IsNil() bool { return false }
|
func (e eventRetryReceived) IsNil() bool { return false }
|
||||||
|
|
||||||
func (e eventRetryReceived) MarshalJSONObject(enc *gojay.Encoder) {
|
func (e eventRetryReceived) MarshalJSONObject(enc *gojay.Encoder) {
|
||||||
enc.StringKey("packet_type", PacketTypeRetry.String())
|
enc.StringKey("packet_type", logging.PacketTypeRetry.String())
|
||||||
enc.ObjectKey("header", e.Header)
|
enc.ObjectKey("header", e.Header)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,7 +173,7 @@ func (e eventVersionNegotiationReceived) Name() string { return "packet_re
|
||||||
func (e eventVersionNegotiationReceived) IsNil() bool { return false }
|
func (e eventVersionNegotiationReceived) IsNil() bool { return false }
|
||||||
|
|
||||||
func (e eventVersionNegotiationReceived) MarshalJSONObject(enc *gojay.Encoder) {
|
func (e eventVersionNegotiationReceived) MarshalJSONObject(enc *gojay.Encoder) {
|
||||||
enc.StringKey("packet_type", PacketTypeVersionNegotiation.String())
|
enc.StringKey("packet_type", logging.PacketTypeVersionNegotiation.String())
|
||||||
enc.ObjectKey("header", e.Header)
|
enc.ObjectKey("header", e.Header)
|
||||||
enc.ArrayKey("supported_versions", versions(e.SupportedVersions))
|
enc.ArrayKey("supported_versions", versions(e.SupportedVersions))
|
||||||
}
|
}
|
||||||
|
@ -186,12 +187,12 @@ func (e eventStatelessResetReceived) Name() string { return "packet_receiv
|
||||||
func (e eventStatelessResetReceived) IsNil() bool { return false }
|
func (e eventStatelessResetReceived) IsNil() bool { return false }
|
||||||
|
|
||||||
func (e eventStatelessResetReceived) MarshalJSONObject(enc *gojay.Encoder) {
|
func (e eventStatelessResetReceived) MarshalJSONObject(enc *gojay.Encoder) {
|
||||||
enc.StringKey("packet_type", PacketTypeStatelessReset.String())
|
enc.StringKey("packet_type", logging.PacketTypeStatelessReset.String())
|
||||||
enc.StringKey("stateless_reset_token", fmt.Sprintf("%x", *e.Token))
|
enc.StringKey("stateless_reset_token", fmt.Sprintf("%x", *e.Token))
|
||||||
}
|
}
|
||||||
|
|
||||||
type eventPacketBuffered struct {
|
type eventPacketBuffered struct {
|
||||||
PacketType PacketType
|
PacketType logging.PacketType
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e eventPacketBuffered) Category() category { return categoryTransport }
|
func (e eventPacketBuffered) Category() category { return categoryTransport }
|
||||||
|
@ -204,9 +205,9 @@ func (e eventPacketBuffered) MarshalJSONObject(enc *gojay.Encoder) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type eventPacketDropped struct {
|
type eventPacketDropped struct {
|
||||||
PacketType PacketType
|
PacketType logging.PacketType
|
||||||
PacketSize protocol.ByteCount
|
PacketSize protocol.ByteCount
|
||||||
Trigger PacketDropReason
|
Trigger logging.PacketDropReason
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e eventPacketDropped) Category() category { return categoryTransport }
|
func (e eventPacketDropped) Category() category { return categoryTransport }
|
||||||
|
@ -277,9 +278,9 @@ func (e eventUpdatedPTO) MarshalJSONObject(enc *gojay.Encoder) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type eventPacketLost struct {
|
type eventPacketLost struct {
|
||||||
PacketType PacketType
|
PacketType logging.PacketType
|
||||||
PacketNumber protocol.PacketNumber
|
PacketNumber protocol.PacketNumber
|
||||||
Trigger PacketLossReason
|
Trigger logging.PacketLossReason
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e eventPacketLost) Category() category { return categoryRecovery }
|
func (e eventPacketLost) Category() category { return categoryRecovery }
|
||||||
|
@ -381,7 +382,7 @@ func (e eventTransportParameters) MarshalJSONObject(enc *gojay.Encoder) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type eventLossTimerSet struct {
|
type eventLossTimerSet struct {
|
||||||
TimerType TimerType
|
TimerType logging.TimerType
|
||||||
EncLevel protocol.EncryptionLevel
|
EncLevel protocol.EncryptionLevel
|
||||||
Delta time.Duration
|
Delta time.Duration
|
||||||
}
|
}
|
||||||
|
@ -398,7 +399,7 @@ func (e eventLossTimerSet) MarshalJSONObject(enc *gojay.Encoder) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type eventLossTimerExpired struct {
|
type eventLossTimerExpired struct {
|
||||||
TimerType TimerType
|
TimerType logging.TimerType
|
||||||
EncLevel protocol.EncryptionLevel
|
EncLevel protocol.EncryptionLevel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,43 +2,21 @@ package qlog
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/francoispqt/gojay"
|
"github.com/francoispqt/gojay"
|
||||||
|
|
||||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||||
"github.com/lucas-clemente/quic-go/internal/wire"
|
"github.com/lucas-clemente/quic-go/internal/wire"
|
||||||
|
"github.com/lucas-clemente/quic-go/logging"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PacketTypeFromHeader determines the packet type from a *wire.Header.
|
func getPacketTypeFromEncryptionLevel(encLevel protocol.EncryptionLevel) logging.PacketType {
|
||||||
func PacketTypeFromHeader(hdr *wire.Header) PacketType {
|
|
||||||
if !hdr.IsLongHeader {
|
|
||||||
return PacketType1RTT
|
|
||||||
}
|
|
||||||
if hdr.Version == 0 {
|
|
||||||
return PacketTypeVersionNegotiation
|
|
||||||
}
|
|
||||||
switch hdr.Type {
|
|
||||||
case protocol.PacketTypeInitial:
|
|
||||||
return PacketTypeInitial
|
|
||||||
case protocol.PacketTypeHandshake:
|
|
||||||
return PacketTypeHandshake
|
|
||||||
case protocol.PacketType0RTT:
|
|
||||||
return PacketType0RTT
|
|
||||||
case protocol.PacketTypeRetry:
|
|
||||||
return PacketTypeRetry
|
|
||||||
default:
|
|
||||||
return PacketTypeNotDetermined
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func getPacketTypeFromEncryptionLevel(encLevel protocol.EncryptionLevel) PacketType {
|
|
||||||
switch encLevel {
|
switch encLevel {
|
||||||
case protocol.EncryptionInitial:
|
case protocol.EncryptionInitial:
|
||||||
return PacketTypeInitial
|
return logging.PacketTypeInitial
|
||||||
case protocol.EncryptionHandshake:
|
case protocol.EncryptionHandshake:
|
||||||
return PacketTypeHandshake
|
return logging.PacketTypeHandshake
|
||||||
case protocol.Encryption0RTT:
|
case protocol.Encryption0RTT:
|
||||||
return PacketType0RTT
|
return logging.PacketType0RTT
|
||||||
case protocol.Encryption1RTT:
|
case protocol.Encryption1RTT:
|
||||||
return PacketType1RTT
|
return logging.PacketType1RTT
|
||||||
default:
|
default:
|
||||||
panic("unknown encryption level")
|
panic("unknown encryption level")
|
||||||
}
|
}
|
||||||
|
@ -46,7 +24,7 @@ func getPacketTypeFromEncryptionLevel(encLevel protocol.EncryptionLevel) PacketT
|
||||||
|
|
||||||
func transformHeader(hdr *wire.Header) *packetHeader {
|
func transformHeader(hdr *wire.Header) *packetHeader {
|
||||||
return &packetHeader{
|
return &packetHeader{
|
||||||
PacketType: PacketTypeFromHeader(hdr),
|
PacketType: logging.PacketTypeFromHeader(hdr),
|
||||||
PayloadLength: hdr.Length,
|
PayloadLength: hdr.Length,
|
||||||
SrcConnectionID: hdr.SrcConnectionID,
|
SrcConnectionID: hdr.SrcConnectionID,
|
||||||
DestConnectionID: hdr.DestConnectionID,
|
DestConnectionID: hdr.DestConnectionID,
|
||||||
|
@ -60,23 +38,11 @@ func transformExtendedHeader(hdr *wire.ExtendedHeader) *packetHeader {
|
||||||
return h
|
return h
|
||||||
}
|
}
|
||||||
|
|
||||||
type packetHeader struct {
|
// We don't log the packet type as a part of the header yet, see https://github.com/quiclog/internet-drafts/issues/40.
|
||||||
// We don't log the packet type as a part of the header yet, see https://github.com/quiclog/internet-drafts/issues/40.
|
type packetHeader logging.PacketHeader
|
||||||
PacketType PacketType
|
|
||||||
|
|
||||||
PacketNumber protocol.PacketNumber
|
|
||||||
PayloadLength protocol.ByteCount
|
|
||||||
// Size of the QUIC packet (QUIC header + payload).
|
|
||||||
// See https://github.com/quiclog/internet-drafts/issues/40.
|
|
||||||
PacketSize protocol.ByteCount
|
|
||||||
|
|
||||||
Version protocol.VersionNumber
|
|
||||||
SrcConnectionID protocol.ConnectionID
|
|
||||||
DestConnectionID protocol.ConnectionID
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h packetHeader) MarshalJSONObject(enc *gojay.Encoder) {
|
func (h packetHeader) MarshalJSONObject(enc *gojay.Encoder) {
|
||||||
if h.PacketType != PacketTypeRetry && h.PacketType != PacketTypeVersionNegotiation {
|
if h.PacketType != logging.PacketTypeRetry && h.PacketType != logging.PacketTypeVersionNegotiation {
|
||||||
enc.Int64Key("packet_number", int64(h.PacketNumber))
|
enc.Int64Key("packet_number", int64(h.PacketNumber))
|
||||||
}
|
}
|
||||||
enc.Int64KeyOmitEmpty("payload_length", int64(h.PayloadLength))
|
enc.Int64KeyOmitEmpty("payload_length", int64(h.PayloadLength))
|
||||||
|
@ -84,7 +50,7 @@ func (h packetHeader) MarshalJSONObject(enc *gojay.Encoder) {
|
||||||
if h.Version != 0 {
|
if h.Version != 0 {
|
||||||
enc.StringKey("version", versionNumber(h.Version).String())
|
enc.StringKey("version", versionNumber(h.Version).String())
|
||||||
}
|
}
|
||||||
if h.PacketType != PacketType1RTT {
|
if h.PacketType != logging.PacketType1RTT {
|
||||||
enc.IntKey("scil", h.SrcConnectionID.Len())
|
enc.IntKey("scil", h.SrcConnectionID.Len())
|
||||||
if h.SrcConnectionID.Len() > 0 {
|
if h.SrcConnectionID.Len() > 0 {
|
||||||
enc.StringKey("scid", connectionID(h.SrcConnectionID).String())
|
enc.StringKey("scid", connectionID(h.SrcConnectionID).String())
|
||||||
|
@ -95,5 +61,3 @@ func (h packetHeader) MarshalJSONObject(enc *gojay.Encoder) {
|
||||||
enc.StringKey("dcid", connectionID(h.DestConnectionID).String())
|
enc.StringKey("dcid", connectionID(h.DestConnectionID).String())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (packetHeader) IsNil() bool { return false }
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
|
|
||||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||||
"github.com/lucas-clemente/quic-go/internal/wire"
|
"github.com/lucas-clemente/quic-go/internal/wire"
|
||||||
|
"github.com/lucas-clemente/quic-go/logging"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
@ -15,59 +16,10 @@ import (
|
||||||
|
|
||||||
var _ = Describe("Packet Header", func() {
|
var _ = Describe("Packet Header", func() {
|
||||||
It("determines the packet type from the encryption level", func() {
|
It("determines the packet type from the encryption level", func() {
|
||||||
Expect(getPacketTypeFromEncryptionLevel(protocol.EncryptionInitial)).To(Equal(PacketTypeInitial))
|
Expect(getPacketTypeFromEncryptionLevel(protocol.EncryptionInitial)).To(Equal(logging.PacketTypeInitial))
|
||||||
Expect(getPacketTypeFromEncryptionLevel(protocol.EncryptionHandshake)).To(Equal(PacketTypeHandshake))
|
Expect(getPacketTypeFromEncryptionLevel(protocol.EncryptionHandshake)).To(Equal(logging.PacketTypeHandshake))
|
||||||
Expect(getPacketTypeFromEncryptionLevel(protocol.Encryption0RTT)).To(Equal(PacketType0RTT))
|
Expect(getPacketTypeFromEncryptionLevel(protocol.Encryption0RTT)).To(Equal(logging.PacketType0RTT))
|
||||||
Expect(getPacketTypeFromEncryptionLevel(protocol.Encryption1RTT)).To(Equal(PacketType1RTT))
|
Expect(getPacketTypeFromEncryptionLevel(protocol.Encryption1RTT)).To(Equal(logging.PacketType1RTT))
|
||||||
})
|
|
||||||
|
|
||||||
Context("determining the packet type from the header", func() {
|
|
||||||
It("recognizes Initial packets", func() {
|
|
||||||
Expect(PacketTypeFromHeader(&wire.Header{
|
|
||||||
IsLongHeader: true,
|
|
||||||
Type: protocol.PacketTypeInitial,
|
|
||||||
Version: protocol.VersionTLS,
|
|
||||||
})).To(Equal(PacketTypeInitial))
|
|
||||||
})
|
|
||||||
|
|
||||||
It("recognizes Handshake packets", func() {
|
|
||||||
Expect(PacketTypeFromHeader(&wire.Header{
|
|
||||||
IsLongHeader: true,
|
|
||||||
Type: protocol.PacketTypeHandshake,
|
|
||||||
Version: protocol.VersionTLS,
|
|
||||||
})).To(Equal(PacketTypeHandshake))
|
|
||||||
})
|
|
||||||
|
|
||||||
It("recognizes Retry packets", func() {
|
|
||||||
Expect(PacketTypeFromHeader(&wire.Header{
|
|
||||||
IsLongHeader: true,
|
|
||||||
Type: protocol.PacketTypeRetry,
|
|
||||||
Version: protocol.VersionTLS,
|
|
||||||
})).To(Equal(PacketTypeRetry))
|
|
||||||
})
|
|
||||||
|
|
||||||
It("recognizes 0-RTT packets", func() {
|
|
||||||
Expect(PacketTypeFromHeader(&wire.Header{
|
|
||||||
IsLongHeader: true,
|
|
||||||
Type: protocol.PacketType0RTT,
|
|
||||||
Version: protocol.VersionTLS,
|
|
||||||
})).To(Equal(PacketType0RTT))
|
|
||||||
})
|
|
||||||
|
|
||||||
It("recognizes Version Negotiation packets", func() {
|
|
||||||
Expect(PacketTypeFromHeader(&wire.Header{IsLongHeader: true})).To(Equal(PacketTypeVersionNegotiation))
|
|
||||||
})
|
|
||||||
|
|
||||||
It("recognizes 1-RTT packets", func() {
|
|
||||||
Expect(PacketTypeFromHeader(&wire.Header{})).To(Equal(PacketType1RTT))
|
|
||||||
})
|
|
||||||
|
|
||||||
It("handles unrecognized packet types", func() {
|
|
||||||
Expect(PacketTypeFromHeader(&wire.Header{
|
|
||||||
IsLongHeader: true,
|
|
||||||
Version: protocol.VersionTLS,
|
|
||||||
})).To(Equal(PacketTypeNotDetermined))
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
Context("marshalling", func() {
|
Context("marshalling", func() {
|
||||||
|
|
46
qlog/qlog.go
46
qlog/qlog.go
|
@ -11,37 +11,13 @@ import (
|
||||||
"github.com/lucas-clemente/quic-go/internal/congestion"
|
"github.com/lucas-clemente/quic-go/internal/congestion"
|
||||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||||
"github.com/lucas-clemente/quic-go/internal/wire"
|
"github.com/lucas-clemente/quic-go/internal/wire"
|
||||||
|
"github.com/lucas-clemente/quic-go/logging"
|
||||||
|
|
||||||
"github.com/francoispqt/gojay"
|
"github.com/francoispqt/gojay"
|
||||||
)
|
)
|
||||||
|
|
||||||
const eventChanSize = 50
|
const eventChanSize = 50
|
||||||
|
|
||||||
// A Tracer records events to be exported to a qlog.
|
|
||||||
type Tracer interface {
|
|
||||||
Export() error
|
|
||||||
StartedConnection(local, remote net.Addr, version protocol.VersionNumber, srcConnID, destConnID protocol.ConnectionID)
|
|
||||||
ClosedConnection(CloseReason)
|
|
||||||
SentTransportParameters(*wire.TransportParameters)
|
|
||||||
ReceivedTransportParameters(*wire.TransportParameters)
|
|
||||||
SentPacket(hdr *wire.ExtendedHeader, packetSize protocol.ByteCount, ack *wire.AckFrame, frames []wire.Frame)
|
|
||||||
ReceivedVersionNegotiationPacket(*wire.Header)
|
|
||||||
ReceivedRetry(*wire.Header)
|
|
||||||
ReceivedPacket(hdr *wire.ExtendedHeader, packetSize protocol.ByteCount, frames []wire.Frame)
|
|
||||||
ReceivedStatelessReset(token *[16]byte)
|
|
||||||
BufferedPacket(PacketType)
|
|
||||||
DroppedPacket(PacketType, protocol.ByteCount, PacketDropReason)
|
|
||||||
UpdatedMetrics(rttStats *congestion.RTTStats, cwnd protocol.ByteCount, bytesInFLight protocol.ByteCount, packetsInFlight int)
|
|
||||||
LostPacket(protocol.EncryptionLevel, protocol.PacketNumber, PacketLossReason)
|
|
||||||
UpdatedPTOCount(value uint32)
|
|
||||||
UpdatedKeyFromTLS(protocol.EncryptionLevel, protocol.Perspective)
|
|
||||||
UpdatedKey(generation protocol.KeyPhase, remote bool)
|
|
||||||
DroppedEncryptionLevel(protocol.EncryptionLevel)
|
|
||||||
SetLossTimer(TimerType, protocol.EncryptionLevel, time.Time)
|
|
||||||
LossTimerExpired(TimerType, protocol.EncryptionLevel)
|
|
||||||
LossTimerCanceled()
|
|
||||||
}
|
|
||||||
|
|
||||||
type tracer struct {
|
type tracer struct {
|
||||||
mutex sync.Mutex
|
mutex sync.Mutex
|
||||||
|
|
||||||
|
@ -58,10 +34,10 @@ type tracer struct {
|
||||||
lastMetrics *metrics
|
lastMetrics *metrics
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ Tracer = &tracer{}
|
var _ logging.Tracer = &tracer{}
|
||||||
|
|
||||||
// NewTracer creates a new tracer to record a qlog.
|
// NewTracer creates a new tracer to record a qlog.
|
||||||
func NewTracer(w io.WriteCloser, p protocol.Perspective, odcid protocol.ConnectionID) Tracer {
|
func NewTracer(w io.WriteCloser, p protocol.Perspective, odcid protocol.ConnectionID) logging.Tracer {
|
||||||
t := &tracer{
|
t := &tracer{
|
||||||
w: w,
|
w: w,
|
||||||
perspective: p,
|
perspective: p,
|
||||||
|
@ -155,7 +131,7 @@ func (t *tracer) StartedConnection(local, remote net.Addr, version protocol.Vers
|
||||||
t.mutex.Unlock()
|
t.mutex.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *tracer) ClosedConnection(r CloseReason) {
|
func (t *tracer) ClosedConnection(r logging.CloseReason) {
|
||||||
t.mutex.Lock()
|
t.mutex.Lock()
|
||||||
t.recordEvent(time.Now(), &eventConnectionClosed{Reason: r})
|
t.recordEvent(time.Now(), &eventConnectionClosed{Reason: r})
|
||||||
t.mutex.Unlock()
|
t.mutex.Unlock()
|
||||||
|
@ -214,7 +190,7 @@ func (t *tracer) SentPacket(hdr *wire.ExtendedHeader, packetSize protocol.ByteCo
|
||||||
header.PacketSize = packetSize
|
header.PacketSize = packetSize
|
||||||
t.mutex.Lock()
|
t.mutex.Lock()
|
||||||
t.recordEvent(time.Now(), &eventPacketSent{
|
t.recordEvent(time.Now(), &eventPacketSent{
|
||||||
PacketType: PacketTypeFromHeader(&hdr.Header),
|
PacketType: logging.PacketTypeFromHeader(&hdr.Header),
|
||||||
Header: header,
|
Header: header,
|
||||||
Frames: fs,
|
Frames: fs,
|
||||||
})
|
})
|
||||||
|
@ -230,7 +206,7 @@ func (t *tracer) ReceivedPacket(hdr *wire.ExtendedHeader, packetSize protocol.By
|
||||||
header.PacketSize = packetSize
|
header.PacketSize = packetSize
|
||||||
t.mutex.Lock()
|
t.mutex.Lock()
|
||||||
t.recordEvent(time.Now(), &eventPacketReceived{
|
t.recordEvent(time.Now(), &eventPacketReceived{
|
||||||
PacketType: PacketTypeFromHeader(&hdr.Header),
|
PacketType: logging.PacketTypeFromHeader(&hdr.Header),
|
||||||
Header: header,
|
Header: header,
|
||||||
Frames: fs,
|
Frames: fs,
|
||||||
})
|
})
|
||||||
|
@ -266,13 +242,13 @@ func (t *tracer) ReceivedStatelessReset(token *[16]byte) {
|
||||||
t.mutex.Unlock()
|
t.mutex.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *tracer) BufferedPacket(packetType PacketType) {
|
func (t *tracer) BufferedPacket(packetType logging.PacketType) {
|
||||||
t.mutex.Lock()
|
t.mutex.Lock()
|
||||||
t.recordEvent(time.Now(), &eventPacketBuffered{PacketType: packetType})
|
t.recordEvent(time.Now(), &eventPacketBuffered{PacketType: packetType})
|
||||||
t.mutex.Unlock()
|
t.mutex.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *tracer) DroppedPacket(packetType PacketType, size protocol.ByteCount, dropReason PacketDropReason) {
|
func (t *tracer) DroppedPacket(packetType logging.PacketType, size protocol.ByteCount, dropReason logging.PacketDropReason) {
|
||||||
t.mutex.Lock()
|
t.mutex.Lock()
|
||||||
t.recordEvent(time.Now(), &eventPacketDropped{
|
t.recordEvent(time.Now(), &eventPacketDropped{
|
||||||
PacketType: packetType,
|
PacketType: packetType,
|
||||||
|
@ -301,7 +277,7 @@ func (t *tracer) UpdatedMetrics(rttStats *congestion.RTTStats, cwnd, bytesInFlig
|
||||||
t.mutex.Unlock()
|
t.mutex.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *tracer) LostPacket(encLevel protocol.EncryptionLevel, pn protocol.PacketNumber, lossReason PacketLossReason) {
|
func (t *tracer) LostPacket(encLevel protocol.EncryptionLevel, pn protocol.PacketNumber, lossReason logging.PacketLossReason) {
|
||||||
t.mutex.Lock()
|
t.mutex.Lock()
|
||||||
t.recordEvent(time.Now(), &eventPacketLost{
|
t.recordEvent(time.Now(), &eventPacketLost{
|
||||||
PacketType: getPacketTypeFromEncryptionLevel(encLevel),
|
PacketType: getPacketTypeFromEncryptionLevel(encLevel),
|
||||||
|
@ -354,7 +330,7 @@ func (t *tracer) DroppedEncryptionLevel(encLevel protocol.EncryptionLevel) {
|
||||||
t.mutex.Unlock()
|
t.mutex.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *tracer) SetLossTimer(tt TimerType, encLevel protocol.EncryptionLevel, timeout time.Time) {
|
func (t *tracer) SetLossTimer(tt logging.TimerType, encLevel protocol.EncryptionLevel, timeout time.Time) {
|
||||||
t.mutex.Lock()
|
t.mutex.Lock()
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
t.recordEvent(now, &eventLossTimerSet{
|
t.recordEvent(now, &eventLossTimerSet{
|
||||||
|
@ -365,7 +341,7 @@ func (t *tracer) SetLossTimer(tt TimerType, encLevel protocol.EncryptionLevel, t
|
||||||
t.mutex.Unlock()
|
t.mutex.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *tracer) LossTimerExpired(tt TimerType, encLevel protocol.EncryptionLevel) {
|
func (t *tracer) LossTimerExpired(tt logging.TimerType, encLevel protocol.EncryptionLevel) {
|
||||||
t.mutex.Lock()
|
t.mutex.Lock()
|
||||||
t.recordEvent(time.Now(), &eventLossTimerExpired{
|
t.recordEvent(time.Now(), &eventLossTimerExpired{
|
||||||
TimerType: tt,
|
TimerType: tt,
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"github.com/lucas-clemente/quic-go/internal/congestion"
|
"github.com/lucas-clemente/quic-go/internal/congestion"
|
||||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||||
"github.com/lucas-clemente/quic-go/internal/wire"
|
"github.com/lucas-clemente/quic-go/internal/wire"
|
||||||
|
"github.com/lucas-clemente/quic-go/logging"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
@ -48,7 +49,7 @@ type entry struct {
|
||||||
|
|
||||||
var _ = Describe("Tracer", func() {
|
var _ = Describe("Tracer", func() {
|
||||||
var (
|
var (
|
||||||
tracer Tracer
|
tracer logging.Tracer
|
||||||
buf *bytes.Buffer
|
buf *bytes.Buffer
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -159,7 +160,7 @@ var _ = Describe("Tracer", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
It("records connection closes", func() {
|
It("records connection closes", func() {
|
||||||
tracer.ClosedConnection(CloseReasonIdleTimeout)
|
tracer.ClosedConnection(logging.CloseReasonIdleTimeout)
|
||||||
entry := exportAndParseSingle()
|
entry := exportAndParseSingle()
|
||||||
Expect(entry.Time).To(BeTemporally("~", time.Now(), scaleDuration(10*time.Millisecond)))
|
Expect(entry.Time).To(BeTemporally("~", time.Now(), scaleDuration(10*time.Millisecond)))
|
||||||
Expect(entry.Category).To(Equal("transport"))
|
Expect(entry.Category).To(Equal("transport"))
|
||||||
|
@ -402,7 +403,7 @@ var _ = Describe("Tracer", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
It("records buffered packets", func() {
|
It("records buffered packets", func() {
|
||||||
tracer.BufferedPacket(PacketTypeHandshake)
|
tracer.BufferedPacket(logging.PacketTypeHandshake)
|
||||||
entry := exportAndParseSingle()
|
entry := exportAndParseSingle()
|
||||||
Expect(entry.Time).To(BeTemporally("~", time.Now(), scaleDuration(10*time.Millisecond)))
|
Expect(entry.Time).To(BeTemporally("~", time.Now(), scaleDuration(10*time.Millisecond)))
|
||||||
Expect(entry.Category).To(Equal("transport"))
|
Expect(entry.Category).To(Equal("transport"))
|
||||||
|
@ -413,7 +414,7 @@ var _ = Describe("Tracer", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
It("records dropped packets", func() {
|
It("records dropped packets", func() {
|
||||||
tracer.DroppedPacket(PacketTypeHandshake, 1337, PacketDropPayloadDecryptError)
|
tracer.DroppedPacket(logging.PacketTypeHandshake, 1337, logging.PacketDropPayloadDecryptError)
|
||||||
entry := exportAndParseSingle()
|
entry := exportAndParseSingle()
|
||||||
Expect(entry.Time).To(BeTemporally("~", time.Now(), scaleDuration(10*time.Millisecond)))
|
Expect(entry.Time).To(BeTemporally("~", time.Now(), scaleDuration(10*time.Millisecond)))
|
||||||
Expect(entry.Category).To(Equal("transport"))
|
Expect(entry.Category).To(Equal("transport"))
|
||||||
|
@ -503,7 +504,7 @@ var _ = Describe("Tracer", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
It("records lost packets", func() {
|
It("records lost packets", func() {
|
||||||
tracer.LostPacket(protocol.EncryptionHandshake, 42, PacketLossReorderingThreshold)
|
tracer.LostPacket(protocol.EncryptionHandshake, 42, logging.PacketLossReorderingThreshold)
|
||||||
entry := exportAndParseSingle()
|
entry := exportAndParseSingle()
|
||||||
Expect(entry.Time).To(BeTemporally("~", time.Now(), scaleDuration(10*time.Millisecond)))
|
Expect(entry.Time).To(BeTemporally("~", time.Now(), scaleDuration(10*time.Millisecond)))
|
||||||
Expect(entry.Category).To(Equal("recovery"))
|
Expect(entry.Category).To(Equal("recovery"))
|
||||||
|
@ -576,7 +577,7 @@ var _ = Describe("Tracer", func() {
|
||||||
|
|
||||||
It("records when the timer is set", func() {
|
It("records when the timer is set", func() {
|
||||||
timeout := time.Now().Add(137 * time.Millisecond)
|
timeout := time.Now().Add(137 * time.Millisecond)
|
||||||
tracer.SetLossTimer(TimerTypePTO, protocol.EncryptionHandshake, timeout)
|
tracer.SetLossTimer(logging.TimerTypePTO, protocol.EncryptionHandshake, timeout)
|
||||||
entry := exportAndParseSingle()
|
entry := exportAndParseSingle()
|
||||||
Expect(entry.Time).To(BeTemporally("~", time.Now(), scaleDuration(10*time.Millisecond)))
|
Expect(entry.Time).To(BeTemporally("~", time.Now(), scaleDuration(10*time.Millisecond)))
|
||||||
Expect(entry.Category).To(Equal("recovery"))
|
Expect(entry.Category).To(Equal("recovery"))
|
||||||
|
@ -592,7 +593,7 @@ var _ = Describe("Tracer", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
It("records when the loss timer expires", func() {
|
It("records when the loss timer expires", func() {
|
||||||
tracer.LossTimerExpired(TimerTypeACK, protocol.Encryption1RTT)
|
tracer.LossTimerExpired(logging.TimerTypeACK, protocol.Encryption1RTT)
|
||||||
entry := exportAndParseSingle()
|
entry := exportAndParseSingle()
|
||||||
Expect(entry.Time).To(BeTemporally("~", time.Now(), scaleDuration(10*time.Millisecond)))
|
Expect(entry.Time).To(BeTemporally("~", time.Now(), scaleDuration(10*time.Millisecond)))
|
||||||
Expect(entry.Category).To(Equal("recovery"))
|
Expect(entry.Category).To(Equal("recovery"))
|
||||||
|
|
173
qlog/types.go
173
qlog/types.go
|
@ -25,12 +25,6 @@ func (o owner) String() string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type versionNumber protocol.VersionNumber
|
|
||||||
|
|
||||||
func (v versionNumber) String() string {
|
|
||||||
return fmt.Sprintf("%x", uint32(v))
|
|
||||||
}
|
|
||||||
|
|
||||||
type streamType protocol.StreamType
|
type streamType protocol.StreamType
|
||||||
|
|
||||||
func (s streamType) String() string {
|
func (s streamType) String() string {
|
||||||
|
@ -75,51 +69,14 @@ func (c category) String() string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// PacketType is the packet type of a QUIC packet
|
type versionNumber protocol.VersionNumber
|
||||||
type PacketType protocol.PacketType
|
|
||||||
|
|
||||||
const (
|
func (v versionNumber) String() string {
|
||||||
// PacketTypeInitial is the packet type of an Initial packet
|
return fmt.Sprintf("%x", uint32(v))
|
||||||
PacketTypeInitial PacketType = iota
|
|
||||||
// PacketTypeHandshake is the packet type of a Handshake packet
|
|
||||||
PacketTypeHandshake
|
|
||||||
// PacketTypeRetry is the packet type of a Retry packet
|
|
||||||
PacketTypeRetry
|
|
||||||
// PacketType0RTT is the packet type of a 0-RTT packet
|
|
||||||
PacketType0RTT
|
|
||||||
// PacketTypeVersionNegotiation is the packet type of a Version Negotiation packet
|
|
||||||
PacketTypeVersionNegotiation
|
|
||||||
// PacketType1RTT is a 1-RTT packet
|
|
||||||
PacketType1RTT
|
|
||||||
// PacketTypeStatelessReset is a stateless reset
|
|
||||||
PacketTypeStatelessReset
|
|
||||||
// PacketTypeNotDetermined is the packet type when it could not be determined
|
|
||||||
PacketTypeNotDetermined
|
|
||||||
)
|
|
||||||
|
|
||||||
func (t PacketType) String() string {
|
|
||||||
switch t {
|
|
||||||
case PacketTypeInitial:
|
|
||||||
return "initial"
|
|
||||||
case PacketTypeHandshake:
|
|
||||||
return "handshake"
|
|
||||||
case PacketTypeRetry:
|
|
||||||
return "retry"
|
|
||||||
case PacketType0RTT:
|
|
||||||
return "0RTT"
|
|
||||||
case PacketTypeVersionNegotiation:
|
|
||||||
return "version_negotiation"
|
|
||||||
case PacketTypeStatelessReset:
|
|
||||||
return "stateless_reset"
|
|
||||||
case PacketType1RTT:
|
|
||||||
return "1RTT"
|
|
||||||
case PacketTypeNotDetermined:
|
|
||||||
return ""
|
|
||||||
default:
|
|
||||||
panic("unknown packet type")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (packetHeader) IsNil() bool { return false }
|
||||||
|
|
||||||
func encLevelToPacketNumberSpace(encLevel protocol.EncryptionLevel) string {
|
func encLevelToPacketNumberSpace(encLevel protocol.EncryptionLevel) string {
|
||||||
switch encLevel {
|
switch encLevel {
|
||||||
case protocol.EncryptionInitial:
|
case protocol.EncryptionInitial:
|
||||||
|
@ -133,26 +90,6 @@ func encLevelToPacketNumberSpace(encLevel protocol.EncryptionLevel) string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type PacketLossReason uint8
|
|
||||||
|
|
||||||
const (
|
|
||||||
// PacketLossReorderingThreshold: when a packet is deemed lost due to reordering threshold
|
|
||||||
PacketLossReorderingThreshold PacketLossReason = iota
|
|
||||||
// PacketLossTimeThreshold: when a packet is deemed lost due to time threshold
|
|
||||||
PacketLossTimeThreshold
|
|
||||||
)
|
|
||||||
|
|
||||||
func (r PacketLossReason) String() string {
|
|
||||||
switch r {
|
|
||||||
case PacketLossReorderingThreshold:
|
|
||||||
return "reordering_threshold"
|
|
||||||
case PacketLossTimeThreshold:
|
|
||||||
return "time_threshold"
|
|
||||||
default:
|
|
||||||
panic("unknown loss reason")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type keyType uint8
|
type keyType uint8
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -239,62 +176,6 @@ func (t keyUpdateTrigger) String() string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type PacketDropReason uint8
|
|
||||||
|
|
||||||
const (
|
|
||||||
// PacketDropKeyUnavailable is used when a packet is dropped because keys are unavailable
|
|
||||||
PacketDropKeyUnavailable PacketDropReason = iota
|
|
||||||
// PacketDropUnknownConnectionID is used when a packet is dropped because the connection ID is unknown
|
|
||||||
PacketDropUnknownConnectionID
|
|
||||||
// PacketDropHeaderParseError is used when a packet is dropped because header parsing failed
|
|
||||||
PacketDropHeaderParseError
|
|
||||||
// PacketDropPayloadDecryptError is used when a packet is dropped because decrypting the payload failed
|
|
||||||
PacketDropPayloadDecryptError
|
|
||||||
// PacketDropProtocolViolation is used when a packet is dropped due to a protocol violation
|
|
||||||
PacketDropProtocolViolation
|
|
||||||
// PacketDropDOSPrevention is used when a packet is dropped to mitigate a DoS attack
|
|
||||||
PacketDropDOSPrevention
|
|
||||||
// PacketDropUnsupportedVersion is used when a packet is dropped because the version is not supported
|
|
||||||
PacketDropUnsupportedVersion
|
|
||||||
// PacketDropUnexpectedPacket is used when an unexpected packet is received
|
|
||||||
PacketDropUnexpectedPacket
|
|
||||||
// PacketDropUnexpectedSourceConnectionID is used when a packet with an unexpected source connection ID is received
|
|
||||||
PacketDropUnexpectedSourceConnectionID
|
|
||||||
// PacketDropUnexpectedVersion is used when a packet with an unexpected version is received
|
|
||||||
PacketDropUnexpectedVersion
|
|
||||||
// PacketDropDuplicate is used when a duplicate packet is received
|
|
||||||
PacketDropDuplicate
|
|
||||||
)
|
|
||||||
|
|
||||||
func (r PacketDropReason) String() string {
|
|
||||||
switch r {
|
|
||||||
case PacketDropKeyUnavailable:
|
|
||||||
return "key_unavailable"
|
|
||||||
case PacketDropUnknownConnectionID:
|
|
||||||
return "unknown_connection_id"
|
|
||||||
case PacketDropHeaderParseError:
|
|
||||||
return "header_parse_error"
|
|
||||||
case PacketDropPayloadDecryptError:
|
|
||||||
return "payload_decrypt_error"
|
|
||||||
case PacketDropProtocolViolation:
|
|
||||||
return "protocol_violation"
|
|
||||||
case PacketDropDOSPrevention:
|
|
||||||
return "dos_prevention"
|
|
||||||
case PacketDropUnsupportedVersion:
|
|
||||||
return "unsupported_version"
|
|
||||||
case PacketDropUnexpectedPacket:
|
|
||||||
return "unexpected_packet"
|
|
||||||
case PacketDropUnexpectedSourceConnectionID:
|
|
||||||
return "unexpected_source_connection_id"
|
|
||||||
case PacketDropUnexpectedVersion:
|
|
||||||
return "unexpected_version"
|
|
||||||
case PacketDropDuplicate:
|
|
||||||
return "duplicate"
|
|
||||||
default:
|
|
||||||
panic("unknown packet drop reason")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type transportError uint64
|
type transportError uint64
|
||||||
|
|
||||||
func (e transportError) String() string {
|
func (e transportError) String() string {
|
||||||
|
@ -331,47 +212,3 @@ func (e transportError) String() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TimerType is the type of the loss detection timer
|
|
||||||
type TimerType uint8
|
|
||||||
|
|
||||||
const (
|
|
||||||
// TimerTypeACK is the timer type for the early retransmit timer
|
|
||||||
TimerTypeACK TimerType = iota
|
|
||||||
// TimerTypePTO is the timer type for the PTO retransmit timer
|
|
||||||
TimerTypePTO
|
|
||||||
)
|
|
||||||
|
|
||||||
func (t TimerType) String() string {
|
|
||||||
switch t {
|
|
||||||
case TimerTypeACK:
|
|
||||||
return "ack"
|
|
||||||
case TimerTypePTO:
|
|
||||||
return "pto"
|
|
||||||
default:
|
|
||||||
panic("unknown timer type")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// CloseReason is the reason why a session is closed
|
|
||||||
type CloseReason uint8
|
|
||||||
|
|
||||||
const (
|
|
||||||
// CloseReasonHandshakeTimeout is used when the session is closed due to a handshake timeout
|
|
||||||
// This reason is not defined in the qlog draft, but very useful for debugging.
|
|
||||||
CloseReasonHandshakeTimeout CloseReason = iota
|
|
||||||
// CloseReasonIdleTimeout is used when the session is closed due to an idle timeout
|
|
||||||
// This reason is not defined in the qlog draft, but very useful for debugging.
|
|
||||||
CloseReasonIdleTimeout
|
|
||||||
)
|
|
||||||
|
|
||||||
func (r CloseReason) String() string {
|
|
||||||
switch r {
|
|
||||||
case CloseReasonHandshakeTimeout:
|
|
||||||
return "handshake_timeout"
|
|
||||||
case CloseReasonIdleTimeout:
|
|
||||||
return "idle_timeout"
|
|
||||||
default:
|
|
||||||
panic("unknown close reason")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -28,17 +28,6 @@ var _ = Describe("Types", func() {
|
||||||
Expect(categorySecurity.String()).To(Equal("security"))
|
Expect(categorySecurity.String()).To(Equal("security"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("has a string representation for the packet type", func() {
|
|
||||||
Expect(PacketTypeInitial.String()).To(Equal("initial"))
|
|
||||||
Expect(PacketTypeHandshake.String()).To(Equal("handshake"))
|
|
||||||
Expect(PacketType0RTT.String()).To(Equal("0RTT"))
|
|
||||||
Expect(PacketType1RTT.String()).To(Equal("1RTT"))
|
|
||||||
Expect(PacketTypeStatelessReset.String()).To(Equal("stateless_reset"))
|
|
||||||
Expect(PacketTypeRetry.String()).To(Equal("retry"))
|
|
||||||
Expect(PacketTypeVersionNegotiation.String()).To(Equal("version_negotiation"))
|
|
||||||
Expect(PacketTypeNotDetermined.String()).To(BeEmpty())
|
|
||||||
})
|
|
||||||
|
|
||||||
It("has a string representation for the key type", func() {
|
It("has a string representation for the key type", func() {
|
||||||
Expect(encLevelToKeyType(protocol.EncryptionInitial, protocol.PerspectiveClient).String()).To(Equal("client_initial_secret"))
|
Expect(encLevelToKeyType(protocol.EncryptionInitial, protocol.PerspectiveClient).String()).To(Equal("client_initial_secret"))
|
||||||
Expect(encLevelToKeyType(protocol.EncryptionInitial, protocol.PerspectiveServer).String()).To(Equal("server_initial_secret"))
|
Expect(encLevelToKeyType(protocol.EncryptionInitial, protocol.PerspectiveServer).String()).To(Equal("server_initial_secret"))
|
||||||
|
@ -63,19 +52,6 @@ var _ = Describe("Types", func() {
|
||||||
Expect(encLevelToPacketNumberSpace(protocol.Encryption1RTT)).To(Equal("application_data"))
|
Expect(encLevelToPacketNumberSpace(protocol.Encryption1RTT)).To(Equal("application_data"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("has a string representation for the packet drop reason", func() {
|
|
||||||
Expect(PacketDropKeyUnavailable.String()).To(Equal("key_unavailable"))
|
|
||||||
Expect(PacketDropUnknownConnectionID.String()).To(Equal("unknown_connection_id"))
|
|
||||||
Expect(PacketDropHeaderParseError.String()).To(Equal("header_parse_error"))
|
|
||||||
Expect(PacketDropPayloadDecryptError.String()).To(Equal("payload_decrypt_error"))
|
|
||||||
Expect(PacketDropProtocolViolation.String()).To(Equal("protocol_violation"))
|
|
||||||
Expect(PacketDropDOSPrevention.String()).To(Equal("dos_prevention"))
|
|
||||||
Expect(PacketDropUnsupportedVersion.String()).To(Equal("unsupported_version"))
|
|
||||||
Expect(PacketDropUnexpectedPacket.String()).To(Equal("unexpected_packet"))
|
|
||||||
Expect(PacketDropUnexpectedSourceConnectionID.String()).To(Equal("unexpected_source_connection_id"))
|
|
||||||
Expect(PacketDropUnexpectedVersion.String()).To(Equal("unexpected_version"))
|
|
||||||
})
|
|
||||||
|
|
||||||
Context("transport errors", func() {
|
Context("transport errors", func() {
|
||||||
It("has a string representation for every error code", func() {
|
It("has a string representation for every error code", func() {
|
||||||
// We parse the error code file, extract all constants, and verify that
|
// We parse the error code file, extract all constants, and verify that
|
||||||
|
@ -113,14 +89,4 @@ var _ = Describe("Types", func() {
|
||||||
Expect(transportError(1337).String()).To(BeEmpty())
|
Expect(transportError(1337).String()).To(BeEmpty())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
It("has a string representation for the timer type", func() {
|
|
||||||
Expect(TimerTypeACK.String()).To(Equal("ack"))
|
|
||||||
Expect(TimerTypePTO.String()).To(Equal("pto"))
|
|
||||||
})
|
|
||||||
|
|
||||||
It("has a string representation for the close reason", func() {
|
|
||||||
Expect(CloseReasonHandshakeTimeout.String()).To(Equal("handshake_timeout"))
|
|
||||||
Expect(CloseReasonIdleTimeout.String()).To(Equal("idle_timeout"))
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
|
@ -16,6 +16,7 @@ import (
|
||||||
"github.com/lucas-clemente/quic-go/internal/qerr"
|
"github.com/lucas-clemente/quic-go/internal/qerr"
|
||||||
"github.com/lucas-clemente/quic-go/internal/utils"
|
"github.com/lucas-clemente/quic-go/internal/utils"
|
||||||
"github.com/lucas-clemente/quic-go/internal/wire"
|
"github.com/lucas-clemente/quic-go/internal/wire"
|
||||||
|
"github.com/lucas-clemente/quic-go/logging"
|
||||||
"github.com/lucas-clemente/quic-go/qlog"
|
"github.com/lucas-clemente/quic-go/qlog"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -86,7 +87,7 @@ type baseServer struct {
|
||||||
*tls.Config,
|
*tls.Config,
|
||||||
*handshake.TokenGenerator,
|
*handshake.TokenGenerator,
|
||||||
bool, /* enable 0-RTT */
|
bool, /* enable 0-RTT */
|
||||||
qlog.Tracer,
|
logging.Tracer,
|
||||||
utils.Logger,
|
utils.Logger,
|
||||||
protocol.VersionNumber,
|
protocol.VersionNumber,
|
||||||
) quicSession
|
) quicSession
|
||||||
|
@ -446,7 +447,7 @@ func (s *baseServer) createNewSession(
|
||||||
) quicSession {
|
) quicSession {
|
||||||
var sess quicSession
|
var sess quicSession
|
||||||
if added := s.sessionHandler.AddWithConnID(clientDestConnID, srcConnID, func() packetHandler {
|
if added := s.sessionHandler.AddWithConnID(clientDestConnID, srcConnID, func() packetHandler {
|
||||||
var qlogger qlog.Tracer
|
var qlogger logging.Tracer
|
||||||
if s.config.GetLogWriter != nil {
|
if s.config.GetLogWriter != nil {
|
||||||
// Use the same connection ID that is passed to the client's GetLogWriter callback.
|
// Use the same connection ID that is passed to the client's GetLogWriter callback.
|
||||||
connID := clientDestConnID
|
connID := clientDestConnID
|
||||||
|
|
|
@ -20,7 +20,7 @@ import (
|
||||||
"github.com/lucas-clemente/quic-go/internal/testdata"
|
"github.com/lucas-clemente/quic-go/internal/testdata"
|
||||||
"github.com/lucas-clemente/quic-go/internal/utils"
|
"github.com/lucas-clemente/quic-go/internal/utils"
|
||||||
"github.com/lucas-clemente/quic-go/internal/wire"
|
"github.com/lucas-clemente/quic-go/internal/wire"
|
||||||
"github.com/lucas-clemente/quic-go/qlog"
|
"github.com/lucas-clemente/quic-go/logging"
|
||||||
"github.com/lucas-clemente/quic-go/quictrace"
|
"github.com/lucas-clemente/quic-go/quictrace"
|
||||||
|
|
||||||
"github.com/golang/mock/gomock"
|
"github.com/golang/mock/gomock"
|
||||||
|
@ -335,7 +335,7 @@ var _ = Describe("Server", func() {
|
||||||
_ *tls.Config,
|
_ *tls.Config,
|
||||||
_ *handshake.TokenGenerator,
|
_ *handshake.TokenGenerator,
|
||||||
enable0RTT bool,
|
enable0RTT bool,
|
||||||
_ qlog.Tracer,
|
_ logging.Tracer,
|
||||||
_ utils.Logger,
|
_ utils.Logger,
|
||||||
_ protocol.VersionNumber,
|
_ protocol.VersionNumber,
|
||||||
) quicSession {
|
) quicSession {
|
||||||
|
@ -508,7 +508,7 @@ var _ = Describe("Server", func() {
|
||||||
_ *tls.Config,
|
_ *tls.Config,
|
||||||
_ *handshake.TokenGenerator,
|
_ *handshake.TokenGenerator,
|
||||||
enable0RTT bool,
|
enable0RTT bool,
|
||||||
_ qlog.Tracer,
|
_ logging.Tracer,
|
||||||
_ utils.Logger,
|
_ utils.Logger,
|
||||||
_ protocol.VersionNumber,
|
_ protocol.VersionNumber,
|
||||||
) quicSession {
|
) quicSession {
|
||||||
|
@ -575,7 +575,7 @@ var _ = Describe("Server", func() {
|
||||||
_ *tls.Config,
|
_ *tls.Config,
|
||||||
_ *handshake.TokenGenerator,
|
_ *handshake.TokenGenerator,
|
||||||
_ bool,
|
_ bool,
|
||||||
_ qlog.Tracer,
|
_ logging.Tracer,
|
||||||
_ utils.Logger,
|
_ utils.Logger,
|
||||||
_ protocol.VersionNumber,
|
_ protocol.VersionNumber,
|
||||||
) quicSession {
|
) quicSession {
|
||||||
|
@ -618,7 +618,7 @@ var _ = Describe("Server", func() {
|
||||||
_ *tls.Config,
|
_ *tls.Config,
|
||||||
_ *handshake.TokenGenerator,
|
_ *handshake.TokenGenerator,
|
||||||
_ bool,
|
_ bool,
|
||||||
_ qlog.Tracer,
|
_ logging.Tracer,
|
||||||
_ utils.Logger,
|
_ utils.Logger,
|
||||||
_ protocol.VersionNumber,
|
_ protocol.VersionNumber,
|
||||||
) quicSession {
|
) quicSession {
|
||||||
|
@ -666,7 +666,7 @@ var _ = Describe("Server", func() {
|
||||||
_ *tls.Config,
|
_ *tls.Config,
|
||||||
_ *handshake.TokenGenerator,
|
_ *handshake.TokenGenerator,
|
||||||
_ bool,
|
_ bool,
|
||||||
_ qlog.Tracer,
|
_ logging.Tracer,
|
||||||
_ utils.Logger,
|
_ utils.Logger,
|
||||||
_ protocol.VersionNumber,
|
_ protocol.VersionNumber,
|
||||||
) quicSession {
|
) quicSession {
|
||||||
|
@ -696,7 +696,7 @@ var _ = Describe("Server", func() {
|
||||||
_ *tls.Config,
|
_ *tls.Config,
|
||||||
_ *handshake.TokenGenerator,
|
_ *handshake.TokenGenerator,
|
||||||
_ bool,
|
_ bool,
|
||||||
_ qlog.Tracer,
|
_ logging.Tracer,
|
||||||
_ utils.Logger,
|
_ utils.Logger,
|
||||||
_ protocol.VersionNumber,
|
_ protocol.VersionNumber,
|
||||||
) quicSession {
|
) quicSession {
|
||||||
|
@ -761,7 +761,7 @@ var _ = Describe("Server", func() {
|
||||||
_ *tls.Config,
|
_ *tls.Config,
|
||||||
_ *handshake.TokenGenerator,
|
_ *handshake.TokenGenerator,
|
||||||
_ bool,
|
_ bool,
|
||||||
_ qlog.Tracer,
|
_ logging.Tracer,
|
||||||
_ utils.Logger,
|
_ utils.Logger,
|
||||||
_ protocol.VersionNumber,
|
_ protocol.VersionNumber,
|
||||||
) quicSession {
|
) quicSession {
|
||||||
|
@ -869,7 +869,7 @@ var _ = Describe("Server", func() {
|
||||||
_ *tls.Config,
|
_ *tls.Config,
|
||||||
_ *handshake.TokenGenerator,
|
_ *handshake.TokenGenerator,
|
||||||
_ bool,
|
_ bool,
|
||||||
_ qlog.Tracer,
|
_ logging.Tracer,
|
||||||
_ utils.Logger,
|
_ utils.Logger,
|
||||||
_ protocol.VersionNumber,
|
_ protocol.VersionNumber,
|
||||||
) quicSession {
|
) quicSession {
|
||||||
|
@ -936,7 +936,7 @@ var _ = Describe("Server", func() {
|
||||||
_ *tls.Config,
|
_ *tls.Config,
|
||||||
_ *handshake.TokenGenerator,
|
_ *handshake.TokenGenerator,
|
||||||
enable0RTT bool,
|
enable0RTT bool,
|
||||||
_ qlog.Tracer,
|
_ logging.Tracer,
|
||||||
_ utils.Logger,
|
_ utils.Logger,
|
||||||
_ protocol.VersionNumber,
|
_ protocol.VersionNumber,
|
||||||
) quicSession {
|
) quicSession {
|
||||||
|
@ -974,7 +974,7 @@ var _ = Describe("Server", func() {
|
||||||
_ *tls.Config,
|
_ *tls.Config,
|
||||||
_ *handshake.TokenGenerator,
|
_ *handshake.TokenGenerator,
|
||||||
_ bool,
|
_ bool,
|
||||||
_ qlog.Tracer,
|
_ logging.Tracer,
|
||||||
_ utils.Logger,
|
_ utils.Logger,
|
||||||
_ protocol.VersionNumber,
|
_ protocol.VersionNumber,
|
||||||
) quicSession {
|
) quicSession {
|
||||||
|
@ -1033,7 +1033,7 @@ var _ = Describe("Server", func() {
|
||||||
_ *tls.Config,
|
_ *tls.Config,
|
||||||
_ *handshake.TokenGenerator,
|
_ *handshake.TokenGenerator,
|
||||||
_ bool,
|
_ bool,
|
||||||
_ qlog.Tracer,
|
_ logging.Tracer,
|
||||||
_ utils.Logger,
|
_ utils.Logger,
|
||||||
_ protocol.VersionNumber,
|
_ protocol.VersionNumber,
|
||||||
) quicSession {
|
) quicSession {
|
||||||
|
|
50
session.go
50
session.go
|
@ -20,7 +20,7 @@ import (
|
||||||
"github.com/lucas-clemente/quic-go/internal/qerr"
|
"github.com/lucas-clemente/quic-go/internal/qerr"
|
||||||
"github.com/lucas-clemente/quic-go/internal/utils"
|
"github.com/lucas-clemente/quic-go/internal/utils"
|
||||||
"github.com/lucas-clemente/quic-go/internal/wire"
|
"github.com/lucas-clemente/quic-go/internal/wire"
|
||||||
"github.com/lucas-clemente/quic-go/qlog"
|
"github.com/lucas-clemente/quic-go/logging"
|
||||||
"github.com/lucas-clemente/quic-go/quictrace"
|
"github.com/lucas-clemente/quic-go/quictrace"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ type session struct {
|
||||||
traceCallback func(quictrace.Event)
|
traceCallback func(quictrace.Event)
|
||||||
|
|
||||||
logID string
|
logID string
|
||||||
qlogger qlog.Tracer
|
qlogger logging.Tracer
|
||||||
logger utils.Logger
|
logger utils.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ var newSession = func(
|
||||||
tlsConf *tls.Config,
|
tlsConf *tls.Config,
|
||||||
tokenGenerator *handshake.TokenGenerator,
|
tokenGenerator *handshake.TokenGenerator,
|
||||||
enable0RTT bool,
|
enable0RTT bool,
|
||||||
qlogger qlog.Tracer,
|
qlogger logging.Tracer,
|
||||||
logger utils.Logger,
|
logger utils.Logger,
|
||||||
v protocol.VersionNumber,
|
v protocol.VersionNumber,
|
||||||
) quicSession {
|
) quicSession {
|
||||||
|
@ -350,7 +350,7 @@ var newClientSession = func(
|
||||||
initialVersion protocol.VersionNumber,
|
initialVersion protocol.VersionNumber,
|
||||||
enable0RTT bool,
|
enable0RTT bool,
|
||||||
hasNegotiatedVersion bool,
|
hasNegotiatedVersion bool,
|
||||||
qlogger qlog.Tracer,
|
qlogger logging.Tracer,
|
||||||
logger utils.Logger,
|
logger utils.Logger,
|
||||||
v protocol.VersionNumber,
|
v protocol.VersionNumber,
|
||||||
) quicSession {
|
) quicSession {
|
||||||
|
@ -592,13 +592,13 @@ runLoop:
|
||||||
s.keepAlivePingSent = true
|
s.keepAlivePingSent = true
|
||||||
} else if !s.handshakeComplete && now.Sub(s.sessionCreationTime) >= s.config.HandshakeTimeout {
|
} else if !s.handshakeComplete && now.Sub(s.sessionCreationTime) >= s.config.HandshakeTimeout {
|
||||||
if s.qlogger != nil {
|
if s.qlogger != nil {
|
||||||
s.qlogger.ClosedConnection(qlog.CloseReasonHandshakeTimeout)
|
s.qlogger.ClosedConnection(logging.CloseReasonHandshakeTimeout)
|
||||||
}
|
}
|
||||||
s.destroyImpl(qerr.NewTimeoutError("Handshake did not complete in time"))
|
s.destroyImpl(qerr.NewTimeoutError("Handshake did not complete in time"))
|
||||||
continue
|
continue
|
||||||
} else if s.handshakeComplete && now.Sub(s.idleTimeoutStartTime()) >= s.idleTimeout {
|
} else if s.handshakeComplete && now.Sub(s.idleTimeoutStartTime()) >= s.idleTimeout {
|
||||||
if s.qlogger != nil {
|
if s.qlogger != nil {
|
||||||
s.qlogger.ClosedConnection(qlog.CloseReasonIdleTimeout)
|
s.qlogger.ClosedConnection(logging.CloseReasonIdleTimeout)
|
||||||
}
|
}
|
||||||
s.destroyImpl(qerr.NewTimeoutError("No recent network activity"))
|
s.destroyImpl(qerr.NewTimeoutError("No recent network activity"))
|
||||||
continue
|
continue
|
||||||
|
@ -727,11 +727,11 @@ func (s *session) handlePacketImpl(rp *receivedPacket) bool {
|
||||||
hdr, packetData, rest, err := wire.ParsePacket(p.data, s.srcConnIDLen)
|
hdr, packetData, rest, err := wire.ParsePacket(p.data, s.srcConnIDLen)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if s.qlogger != nil {
|
if s.qlogger != nil {
|
||||||
dropReason := qlog.PacketDropHeaderParseError
|
dropReason := logging.PacketDropHeaderParseError
|
||||||
if err == wire.ErrUnsupportedVersion {
|
if err == wire.ErrUnsupportedVersion {
|
||||||
dropReason = qlog.PacketDropUnsupportedVersion
|
dropReason = logging.PacketDropUnsupportedVersion
|
||||||
}
|
}
|
||||||
s.qlogger.DroppedPacket(qlog.PacketTypeNotDetermined, protocol.ByteCount(len(data)), dropReason)
|
s.qlogger.DroppedPacket(logging.PacketTypeNotDetermined, protocol.ByteCount(len(data)), dropReason)
|
||||||
}
|
}
|
||||||
s.logger.Debugf("error parsing packet: %s", err)
|
s.logger.Debugf("error parsing packet: %s", err)
|
||||||
break
|
break
|
||||||
|
@ -739,7 +739,7 @@ func (s *session) handlePacketImpl(rp *receivedPacket) bool {
|
||||||
|
|
||||||
if hdr.IsLongHeader && hdr.Version != s.version {
|
if hdr.IsLongHeader && hdr.Version != s.version {
|
||||||
if s.qlogger != nil {
|
if s.qlogger != nil {
|
||||||
s.qlogger.DroppedPacket(qlog.PacketTypeFromHeader(hdr), protocol.ByteCount(len(data)), qlog.PacketDropUnexpectedVersion)
|
s.qlogger.DroppedPacket(logging.PacketTypeFromHeader(hdr), protocol.ByteCount(len(data)), logging.PacketDropUnexpectedVersion)
|
||||||
}
|
}
|
||||||
s.logger.Debugf("Dropping packet with version %x. Expected %x.", hdr.Version, s.version)
|
s.logger.Debugf("Dropping packet with version %x. Expected %x.", hdr.Version, s.version)
|
||||||
break
|
break
|
||||||
|
@ -747,7 +747,7 @@ func (s *session) handlePacketImpl(rp *receivedPacket) bool {
|
||||||
|
|
||||||
if counter > 0 && !hdr.DestConnectionID.Equal(lastConnID) {
|
if counter > 0 && !hdr.DestConnectionID.Equal(lastConnID) {
|
||||||
if s.qlogger != nil {
|
if s.qlogger != nil {
|
||||||
s.qlogger.DroppedPacket(qlog.PacketTypeFromHeader(hdr), protocol.ByteCount(len(data)), qlog.PacketDropUnknownConnectionID)
|
s.qlogger.DroppedPacket(logging.PacketTypeFromHeader(hdr), protocol.ByteCount(len(data)), logging.PacketDropUnknownConnectionID)
|
||||||
}
|
}
|
||||||
s.logger.Debugf("coalesced packet has different destination connection ID: %s, expected %s", hdr.DestConnectionID, lastConnID)
|
s.logger.Debugf("coalesced packet has different destination connection ID: %s, expected %s", hdr.DestConnectionID, lastConnID)
|
||||||
break
|
break
|
||||||
|
@ -791,14 +791,14 @@ func (s *session) handleSinglePacket(p *receivedPacket, hdr *wire.Header) bool /
|
||||||
// After this, all packets with a different source connection have to be ignored.
|
// After this, all packets with a different source connection have to be ignored.
|
||||||
if s.receivedFirstPacket && hdr.IsLongHeader && !hdr.SrcConnectionID.Equal(s.handshakeDestConnID) {
|
if s.receivedFirstPacket && hdr.IsLongHeader && !hdr.SrcConnectionID.Equal(s.handshakeDestConnID) {
|
||||||
if s.qlogger != nil {
|
if s.qlogger != nil {
|
||||||
s.qlogger.DroppedPacket(qlog.PacketTypeFromHeader(hdr), protocol.ByteCount(len(p.data)), qlog.PacketDropUnknownConnectionID)
|
s.qlogger.DroppedPacket(logging.PacketTypeFromHeader(hdr), protocol.ByteCount(len(p.data)), logging.PacketDropUnknownConnectionID)
|
||||||
}
|
}
|
||||||
s.logger.Debugf("Dropping %s packet (%d bytes) with unexpected source connection ID: %s (expected %s)", hdr.PacketType(), len(p.data), hdr.SrcConnectionID, s.handshakeDestConnID)
|
s.logger.Debugf("Dropping %s packet (%d bytes) with unexpected source connection ID: %s (expected %s)", hdr.PacketType(), len(p.data), hdr.SrcConnectionID, s.handshakeDestConnID)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
// drop 0-RTT packets, if we are a client
|
// drop 0-RTT packets, if we are a client
|
||||||
if s.perspective == protocol.PerspectiveClient && hdr.Type == protocol.PacketType0RTT {
|
if s.perspective == protocol.PerspectiveClient && hdr.Type == protocol.PacketType0RTT {
|
||||||
s.qlogger.DroppedPacket(qlog.PacketType0RTT, protocol.ByteCount(len(p.data)), qlog.PacketDropKeyUnavailable)
|
s.qlogger.DroppedPacket(logging.PacketType0RTT, protocol.ByteCount(len(p.data)), logging.PacketDropKeyUnavailable)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -807,7 +807,7 @@ func (s *session) handleSinglePacket(p *receivedPacket, hdr *wire.Header) bool /
|
||||||
switch err {
|
switch err {
|
||||||
case handshake.ErrKeysDropped:
|
case handshake.ErrKeysDropped:
|
||||||
if s.qlogger != nil {
|
if s.qlogger != nil {
|
||||||
s.qlogger.DroppedPacket(qlog.PacketTypeFromHeader(hdr), protocol.ByteCount(len(p.data)), qlog.PacketDropKeyUnavailable)
|
s.qlogger.DroppedPacket(logging.PacketTypeFromHeader(hdr), protocol.ByteCount(len(p.data)), logging.PacketDropKeyUnavailable)
|
||||||
}
|
}
|
||||||
s.logger.Debugf("Dropping %s packet (%d bytes) because we already dropped the keys.", hdr.PacketType(), len(p.data))
|
s.logger.Debugf("Dropping %s packet (%d bytes) because we already dropped the keys.", hdr.PacketType(), len(p.data))
|
||||||
case handshake.ErrKeysNotYetAvailable:
|
case handshake.ErrKeysNotYetAvailable:
|
||||||
|
@ -821,7 +821,7 @@ func (s *session) handleSinglePacket(p *receivedPacket, hdr *wire.Header) bool /
|
||||||
// This might be a packet injected by an attacker.
|
// This might be a packet injected by an attacker.
|
||||||
// Drop it.
|
// Drop it.
|
||||||
if s.qlogger != nil {
|
if s.qlogger != nil {
|
||||||
s.qlogger.DroppedPacket(qlog.PacketTypeFromHeader(hdr), protocol.ByteCount(len(p.data)), qlog.PacketDropPayloadDecryptError)
|
s.qlogger.DroppedPacket(logging.PacketTypeFromHeader(hdr), protocol.ByteCount(len(p.data)), logging.PacketDropPayloadDecryptError)
|
||||||
}
|
}
|
||||||
s.logger.Debugf("Dropping %s packet (%d bytes) that could not be unpacked. Error: %s", hdr.PacketType(), len(p.data), err)
|
s.logger.Debugf("Dropping %s packet (%d bytes) that could not be unpacked. Error: %s", hdr.PacketType(), len(p.data), err)
|
||||||
}
|
}
|
||||||
|
@ -836,7 +836,7 @@ func (s *session) handleSinglePacket(p *receivedPacket, hdr *wire.Header) bool /
|
||||||
if s.receivedPacketHandler.IsPotentiallyDuplicate(packet.packetNumber, packet.encryptionLevel) {
|
if s.receivedPacketHandler.IsPotentiallyDuplicate(packet.packetNumber, packet.encryptionLevel) {
|
||||||
s.logger.Debugf("Dropping (potentially) duplicate packet.")
|
s.logger.Debugf("Dropping (potentially) duplicate packet.")
|
||||||
if s.qlogger != nil {
|
if s.qlogger != nil {
|
||||||
s.qlogger.DroppedPacket(qlog.PacketTypeFromHeader(hdr), protocol.ByteCount(len(p.data)), qlog.PacketDropDuplicate)
|
s.qlogger.DroppedPacket(logging.PacketTypeFromHeader(hdr), protocol.ByteCount(len(p.data)), logging.PacketDropDuplicate)
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -852,14 +852,14 @@ func (s *session) handleRetryPacket(hdr *wire.Header, data []byte) bool /* was t
|
||||||
(&wire.ExtendedHeader{Header: *hdr}).Log(s.logger)
|
(&wire.ExtendedHeader{Header: *hdr}).Log(s.logger)
|
||||||
if s.perspective == protocol.PerspectiveServer {
|
if s.perspective == protocol.PerspectiveServer {
|
||||||
if s.qlogger != nil {
|
if s.qlogger != nil {
|
||||||
s.qlogger.DroppedPacket(qlog.PacketTypeRetry, protocol.ByteCount(len(data)), qlog.PacketDropUnexpectedPacket)
|
s.qlogger.DroppedPacket(logging.PacketTypeRetry, protocol.ByteCount(len(data)), logging.PacketDropUnexpectedPacket)
|
||||||
}
|
}
|
||||||
s.logger.Debugf("Ignoring Retry.")
|
s.logger.Debugf("Ignoring Retry.")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if s.receivedFirstPacket {
|
if s.receivedFirstPacket {
|
||||||
if s.qlogger != nil {
|
if s.qlogger != nil {
|
||||||
s.qlogger.DroppedPacket(qlog.PacketTypeRetry, protocol.ByteCount(len(data)), qlog.PacketDropUnexpectedPacket)
|
s.qlogger.DroppedPacket(logging.PacketTypeRetry, protocol.ByteCount(len(data)), logging.PacketDropUnexpectedPacket)
|
||||||
}
|
}
|
||||||
s.logger.Debugf("Ignoring Retry, since we already received a packet.")
|
s.logger.Debugf("Ignoring Retry, since we already received a packet.")
|
||||||
return false
|
return false
|
||||||
|
@ -867,7 +867,7 @@ func (s *session) handleRetryPacket(hdr *wire.Header, data []byte) bool /* was t
|
||||||
destConnID := s.connIDManager.Get()
|
destConnID := s.connIDManager.Get()
|
||||||
if hdr.SrcConnectionID.Equal(destConnID) {
|
if hdr.SrcConnectionID.Equal(destConnID) {
|
||||||
if s.qlogger != nil {
|
if s.qlogger != nil {
|
||||||
s.qlogger.DroppedPacket(qlog.PacketTypeRetry, protocol.ByteCount(len(data)), qlog.PacketDropUnexpectedPacket)
|
s.qlogger.DroppedPacket(logging.PacketTypeRetry, protocol.ByteCount(len(data)), logging.PacketDropUnexpectedPacket)
|
||||||
}
|
}
|
||||||
s.logger.Debugf("Ignoring Retry, since the server didn't change the Source Connection ID.")
|
s.logger.Debugf("Ignoring Retry, since the server didn't change the Source Connection ID.")
|
||||||
return false
|
return false
|
||||||
|
@ -882,7 +882,7 @@ func (s *session) handleRetryPacket(hdr *wire.Header, data []byte) bool /* was t
|
||||||
tag := handshake.GetRetryIntegrityTag(data[:len(data)-16], destConnID)
|
tag := handshake.GetRetryIntegrityTag(data[:len(data)-16], destConnID)
|
||||||
if !bytes.Equal(data[len(data)-16:], tag[:]) {
|
if !bytes.Equal(data[len(data)-16:], tag[:]) {
|
||||||
if s.qlogger != nil {
|
if s.qlogger != nil {
|
||||||
s.qlogger.DroppedPacket(qlog.PacketTypeRetry, protocol.ByteCount(len(data)), qlog.PacketDropPayloadDecryptError)
|
s.qlogger.DroppedPacket(logging.PacketTypeRetry, protocol.ByteCount(len(data)), logging.PacketDropPayloadDecryptError)
|
||||||
}
|
}
|
||||||
s.logger.Debugf("Ignoring spoofed Retry. Integrity Tag doesn't match.")
|
s.logger.Debugf("Ignoring spoofed Retry. Integrity Tag doesn't match.")
|
||||||
return false
|
return false
|
||||||
|
@ -912,7 +912,7 @@ func (s *session) handleVersionNegotiationPacket(p *receivedPacket) {
|
||||||
if s.perspective == protocol.PerspectiveServer || // servers never receive version negotiation packets
|
if s.perspective == protocol.PerspectiveServer || // servers never receive version negotiation packets
|
||||||
s.receivedFirstPacket || s.versionNegotiated { // ignore delayed / duplicated version negotiation packets
|
s.receivedFirstPacket || s.versionNegotiated { // ignore delayed / duplicated version negotiation packets
|
||||||
if s.qlogger != nil {
|
if s.qlogger != nil {
|
||||||
s.qlogger.DroppedPacket(qlog.PacketTypeVersionNegotiation, protocol.ByteCount(len(p.data)), qlog.PacketDropUnexpectedPacket)
|
s.qlogger.DroppedPacket(logging.PacketTypeVersionNegotiation, protocol.ByteCount(len(p.data)), logging.PacketDropUnexpectedPacket)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -920,7 +920,7 @@ func (s *session) handleVersionNegotiationPacket(p *receivedPacket) {
|
||||||
hdr, _, _, err := wire.ParsePacket(p.data, 0)
|
hdr, _, _, err := wire.ParsePacket(p.data, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if s.qlogger != nil {
|
if s.qlogger != nil {
|
||||||
s.qlogger.DroppedPacket(qlog.PacketTypeVersionNegotiation, protocol.ByteCount(len(p.data)), qlog.PacketDropHeaderParseError)
|
s.qlogger.DroppedPacket(logging.PacketTypeVersionNegotiation, protocol.ByteCount(len(p.data)), logging.PacketDropHeaderParseError)
|
||||||
}
|
}
|
||||||
s.logger.Debugf("Error parsing Version Negotiation packet: %s", err)
|
s.logger.Debugf("Error parsing Version Negotiation packet: %s", err)
|
||||||
return
|
return
|
||||||
|
@ -929,7 +929,7 @@ func (s *session) handleVersionNegotiationPacket(p *receivedPacket) {
|
||||||
for _, v := range hdr.SupportedVersions {
|
for _, v := range hdr.SupportedVersions {
|
||||||
if v == s.version {
|
if v == s.version {
|
||||||
if s.qlogger != nil {
|
if s.qlogger != nil {
|
||||||
s.qlogger.DroppedPacket(qlog.PacketTypeVersionNegotiation, protocol.ByteCount(len(p.data)), qlog.PacketDropUnexpectedVersion)
|
s.qlogger.DroppedPacket(logging.PacketTypeVersionNegotiation, protocol.ByteCount(len(p.data)), logging.PacketDropUnexpectedVersion)
|
||||||
}
|
}
|
||||||
// The Version Negotiation packet contains the version that we offered.
|
// The Version Negotiation packet contains the version that we offered.
|
||||||
// This might be a packet sent by an attacker, or it was corrupted.
|
// This might be a packet sent by an attacker, or it was corrupted.
|
||||||
|
@ -1677,14 +1677,14 @@ func (s *session) scheduleSending() {
|
||||||
func (s *session) tryQueueingUndecryptablePacket(p *receivedPacket, hdr *wire.Header) {
|
func (s *session) tryQueueingUndecryptablePacket(p *receivedPacket, hdr *wire.Header) {
|
||||||
if len(s.undecryptablePackets)+1 > protocol.MaxUndecryptablePackets {
|
if len(s.undecryptablePackets)+1 > protocol.MaxUndecryptablePackets {
|
||||||
if s.qlogger != nil {
|
if s.qlogger != nil {
|
||||||
s.qlogger.DroppedPacket(qlog.PacketTypeFromHeader(hdr), protocol.ByteCount(len(p.data)), qlog.PacketDropDOSPrevention)
|
s.qlogger.DroppedPacket(logging.PacketTypeFromHeader(hdr), protocol.ByteCount(len(p.data)), logging.PacketDropDOSPrevention)
|
||||||
}
|
}
|
||||||
s.logger.Infof("Dropping undecryptable packet (%d bytes). Undecryptable packet queue full.", len(p.data))
|
s.logger.Infof("Dropping undecryptable packet (%d bytes). Undecryptable packet queue full.", len(p.data))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
s.logger.Infof("Queueing packet (%d bytes) for later decryption", len(p.data))
|
s.logger.Infof("Queueing packet (%d bytes) for later decryption", len(p.data))
|
||||||
if s.qlogger != nil {
|
if s.qlogger != nil {
|
||||||
s.qlogger.BufferedPacket(qlog.PacketTypeFromHeader(hdr))
|
s.qlogger.BufferedPacket(logging.PacketTypeFromHeader(hdr))
|
||||||
}
|
}
|
||||||
s.undecryptablePackets = append(s.undecryptablePackets, p)
|
s.undecryptablePackets = append(s.undecryptablePackets, p)
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ import (
|
||||||
"github.com/lucas-clemente/quic-go/internal/testutils"
|
"github.com/lucas-clemente/quic-go/internal/testutils"
|
||||||
"github.com/lucas-clemente/quic-go/internal/utils"
|
"github.com/lucas-clemente/quic-go/internal/utils"
|
||||||
"github.com/lucas-clemente/quic-go/internal/wire"
|
"github.com/lucas-clemente/quic-go/internal/wire"
|
||||||
"github.com/lucas-clemente/quic-go/qlog"
|
"github.com/lucas-clemente/quic-go/logging"
|
||||||
|
|
||||||
"github.com/golang/mock/gomock"
|
"github.com/golang/mock/gomock"
|
||||||
|
|
||||||
|
@ -587,14 +587,14 @@ var _ = Describe("Session", func() {
|
||||||
Version: sess.version,
|
Version: sess.version,
|
||||||
Token: []byte("foobar"),
|
Token: []byte("foobar"),
|
||||||
}}, make([]byte, 16) /* Retry integrity tag */)
|
}}, make([]byte, 16) /* Retry integrity tag */)
|
||||||
qlogger.EXPECT().DroppedPacket(qlog.PacketTypeRetry, protocol.ByteCount(len(p.data)), qlog.PacketDropUnexpectedPacket)
|
qlogger.EXPECT().DroppedPacket(logging.PacketTypeRetry, protocol.ByteCount(len(p.data)), logging.PacketDropUnexpectedPacket)
|
||||||
Expect(sess.handlePacketImpl(p)).To(BeFalse())
|
Expect(sess.handlePacketImpl(p)).To(BeFalse())
|
||||||
})
|
})
|
||||||
|
|
||||||
It("drops Version Negotiation packets", func() {
|
It("drops Version Negotiation packets", func() {
|
||||||
b, err := wire.ComposeVersionNegotiation(srcConnID, destConnID, sess.config.Versions)
|
b, err := wire.ComposeVersionNegotiation(srcConnID, destConnID, sess.config.Versions)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
qlogger.EXPECT().DroppedPacket(qlog.PacketTypeVersionNegotiation, protocol.ByteCount(len(b)), qlog.PacketDropUnexpectedPacket)
|
qlogger.EXPECT().DroppedPacket(logging.PacketTypeVersionNegotiation, protocol.ByteCount(len(b)), logging.PacketDropUnexpectedPacket)
|
||||||
Expect(sess.handlePacketImpl(&receivedPacket{
|
Expect(sess.handlePacketImpl(&receivedPacket{
|
||||||
data: b,
|
data: b,
|
||||||
buffer: getPacketBuffer(),
|
buffer: getPacketBuffer(),
|
||||||
|
@ -611,7 +611,7 @@ var _ = Describe("Session", func() {
|
||||||
PacketNumberLen: protocol.PacketNumberLen2,
|
PacketNumberLen: protocol.PacketNumberLen2,
|
||||||
}, nil)
|
}, nil)
|
||||||
p.data[0] ^= 0x40 // unset the QUIC bit
|
p.data[0] ^= 0x40 // unset the QUIC bit
|
||||||
qlogger.EXPECT().DroppedPacket(qlog.PacketTypeNotDetermined, protocol.ByteCount(len(p.data)), qlog.PacketDropHeaderParseError)
|
qlogger.EXPECT().DroppedPacket(logging.PacketTypeNotDetermined, protocol.ByteCount(len(p.data)), logging.PacketDropHeaderParseError)
|
||||||
Expect(sess.handlePacketImpl(p)).To(BeFalse())
|
Expect(sess.handlePacketImpl(p)).To(BeFalse())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -624,7 +624,7 @@ var _ = Describe("Session", func() {
|
||||||
},
|
},
|
||||||
PacketNumberLen: protocol.PacketNumberLen2,
|
PacketNumberLen: protocol.PacketNumberLen2,
|
||||||
}, nil)
|
}, nil)
|
||||||
qlogger.EXPECT().DroppedPacket(qlog.PacketTypeNotDetermined, protocol.ByteCount(len(p.data)), qlog.PacketDropUnsupportedVersion)
|
qlogger.EXPECT().DroppedPacket(logging.PacketTypeNotDetermined, protocol.ByteCount(len(p.data)), logging.PacketDropUnsupportedVersion)
|
||||||
Expect(sess.handlePacketImpl(p)).To(BeFalse())
|
Expect(sess.handlePacketImpl(p)).To(BeFalse())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -646,7 +646,7 @@ var _ = Describe("Session", func() {
|
||||||
},
|
},
|
||||||
PacketNumberLen: protocol.PacketNumberLen2,
|
PacketNumberLen: protocol.PacketNumberLen2,
|
||||||
}, nil)
|
}, nil)
|
||||||
qlogger.EXPECT().DroppedPacket(qlog.PacketTypeHandshake, protocol.ByteCount(len(p.data)), qlog.PacketDropUnexpectedVersion)
|
qlogger.EXPECT().DroppedPacket(logging.PacketTypeHandshake, protocol.ByteCount(len(p.data)), logging.PacketDropUnexpectedVersion)
|
||||||
Expect(sess.handlePacketImpl(p)).To(BeFalse())
|
Expect(sess.handlePacketImpl(p)).To(BeFalse())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -720,7 +720,7 @@ var _ = Describe("Session", func() {
|
||||||
rph := mockackhandler.NewMockReceivedPacketHandler(mockCtrl)
|
rph := mockackhandler.NewMockReceivedPacketHandler(mockCtrl)
|
||||||
rph.EXPECT().IsPotentiallyDuplicate(protocol.PacketNumber(0x1337), protocol.Encryption1RTT).Return(true)
|
rph.EXPECT().IsPotentiallyDuplicate(protocol.PacketNumber(0x1337), protocol.Encryption1RTT).Return(true)
|
||||||
sess.receivedPacketHandler = rph
|
sess.receivedPacketHandler = rph
|
||||||
qlogger.EXPECT().DroppedPacket(qlog.PacketType1RTT, protocol.ByteCount(len(packet.data)), qlog.PacketDropDuplicate)
|
qlogger.EXPECT().DroppedPacket(logging.PacketType1RTT, protocol.ByteCount(len(packet.data)), logging.PacketDropDuplicate)
|
||||||
Expect(sess.handlePacketImpl(packet)).To(BeFalse())
|
Expect(sess.handlePacketImpl(packet)).To(BeFalse())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -746,7 +746,7 @@ var _ = Describe("Session", func() {
|
||||||
PacketNumber: 0x1337,
|
PacketNumber: 0x1337,
|
||||||
PacketNumberLen: protocol.PacketNumberLen2,
|
PacketNumberLen: protocol.PacketNumberLen2,
|
||||||
}, []byte("foobar"))
|
}, []byte("foobar"))
|
||||||
qlogger.EXPECT().DroppedPacket(qlog.PacketTypeHandshake, protocol.ByteCount(len(p.data)), qlog.PacketDropPayloadDecryptError)
|
qlogger.EXPECT().DroppedPacket(logging.PacketTypeHandshake, protocol.ByteCount(len(p.data)), logging.PacketDropPayloadDecryptError)
|
||||||
sess.handlePacket(p)
|
sess.handlePacket(p)
|
||||||
Consistently(sess.Context().Done()).ShouldNot(BeClosed())
|
Consistently(sess.Context().Done()).ShouldNot(BeClosed())
|
||||||
// make the go routine return
|
// make the go routine return
|
||||||
|
@ -794,7 +794,7 @@ var _ = Describe("Session", func() {
|
||||||
runErr <- sess.run()
|
runErr <- sess.run()
|
||||||
}()
|
}()
|
||||||
expectReplaceWithClosed()
|
expectReplaceWithClosed()
|
||||||
qlogger.EXPECT().DroppedPacket(qlog.PacketType1RTT, gomock.Any(), qlog.PacketDropPayloadDecryptError)
|
qlogger.EXPECT().DroppedPacket(logging.PacketType1RTT, gomock.Any(), logging.PacketDropPayloadDecryptError)
|
||||||
sess.handlePacket(getPacket(&wire.ExtendedHeader{
|
sess.handlePacket(getPacket(&wire.ExtendedHeader{
|
||||||
Header: wire.Header{DestConnectionID: srcConnID},
|
Header: wire.Header{DestConnectionID: srcConnID},
|
||||||
PacketNumberLen: protocol.PacketNumberLen1,
|
PacketNumberLen: protocol.PacketNumberLen1,
|
||||||
|
@ -872,7 +872,7 @@ var _ = Describe("Session", func() {
|
||||||
Expect(sess.handlePacketImpl(p1)).To(BeTrue())
|
Expect(sess.handlePacketImpl(p1)).To(BeTrue())
|
||||||
// The next packet has to be ignored, since the source connection ID doesn't match.
|
// The next packet has to be ignored, since the source connection ID doesn't match.
|
||||||
p2 := getPacket(hdr2, nil)
|
p2 := getPacket(hdr2, nil)
|
||||||
qlogger.EXPECT().DroppedPacket(qlog.PacketTypeHandshake, protocol.ByteCount(len(p2.data)), qlog.PacketDropUnknownConnectionID)
|
qlogger.EXPECT().DroppedPacket(logging.PacketTypeHandshake, protocol.ByteCount(len(p2.data)), logging.PacketDropUnknownConnectionID)
|
||||||
Expect(sess.handlePacketImpl(p2)).To(BeFalse())
|
Expect(sess.handlePacketImpl(p2)).To(BeFalse())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -892,7 +892,7 @@ var _ = Describe("Session", func() {
|
||||||
}
|
}
|
||||||
unpacker.EXPECT().Unpack(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, handshake.ErrKeysNotYetAvailable)
|
unpacker.EXPECT().Unpack(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, handshake.ErrKeysNotYetAvailable)
|
||||||
packet := getPacket(hdr, nil)
|
packet := getPacket(hdr, nil)
|
||||||
qlogger.EXPECT().BufferedPacket(qlog.PacketTypeHandshake)
|
qlogger.EXPECT().BufferedPacket(logging.PacketTypeHandshake)
|
||||||
Expect(sess.handlePacketImpl(packet)).To(BeFalse())
|
Expect(sess.handlePacketImpl(packet)).To(BeFalse())
|
||||||
Expect(sess.undecryptablePackets).To(Equal([]*receivedPacket{packet}))
|
Expect(sess.undecryptablePackets).To(Equal([]*receivedPacket{packet}))
|
||||||
})
|
})
|
||||||
|
@ -1023,7 +1023,7 @@ var _ = Describe("Session", func() {
|
||||||
// don't EXPECT any more calls to unpacker.Unpack()
|
// don't EXPECT any more calls to unpacker.Unpack()
|
||||||
gomock.InOrder(
|
gomock.InOrder(
|
||||||
qlogger.EXPECT().ReceivedPacket(gomock.Any(), protocol.ByteCount(len(packet1.data)), gomock.Any()),
|
qlogger.EXPECT().ReceivedPacket(gomock.Any(), protocol.ByteCount(len(packet1.data)), gomock.Any()),
|
||||||
qlogger.EXPECT().DroppedPacket(gomock.Any(), protocol.ByteCount(len(packet2.data)), qlog.PacketDropUnknownConnectionID),
|
qlogger.EXPECT().DroppedPacket(gomock.Any(), protocol.ByteCount(len(packet2.data)), logging.PacketDropUnknownConnectionID),
|
||||||
)
|
)
|
||||||
packet1.data = append(packet1.data, packet2.data...)
|
packet1.data = append(packet1.data, packet2.data...)
|
||||||
Expect(sess.handlePacketImpl(packet1)).To(BeTrue())
|
Expect(sess.handlePacketImpl(packet1)).To(BeTrue())
|
||||||
|
@ -1789,7 +1789,7 @@ var _ = Describe("Session", func() {
|
||||||
done := make(chan struct{})
|
done := make(chan struct{})
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
gomock.InOrder(
|
gomock.InOrder(
|
||||||
qlogger.EXPECT().ClosedConnection(qlog.CloseReasonIdleTimeout),
|
qlogger.EXPECT().ClosedConnection(logging.CloseReasonIdleTimeout),
|
||||||
qlogger.EXPECT().Export(),
|
qlogger.EXPECT().Export(),
|
||||||
)
|
)
|
||||||
go func() {
|
go func() {
|
||||||
|
@ -1811,7 +1811,7 @@ var _ = Describe("Session", func() {
|
||||||
sessionRunner.EXPECT().Remove(gomock.Any()).Times(2)
|
sessionRunner.EXPECT().Remove(gomock.Any()).Times(2)
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
gomock.InOrder(
|
gomock.InOrder(
|
||||||
qlogger.EXPECT().ClosedConnection(qlog.CloseReasonHandshakeTimeout),
|
qlogger.EXPECT().ClosedConnection(logging.CloseReasonHandshakeTimeout),
|
||||||
qlogger.EXPECT().Export(),
|
qlogger.EXPECT().Export(),
|
||||||
)
|
)
|
||||||
done := make(chan struct{})
|
done := make(chan struct{})
|
||||||
|
@ -1861,7 +1861,7 @@ var _ = Describe("Session", func() {
|
||||||
)
|
)
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
gomock.InOrder(
|
gomock.InOrder(
|
||||||
qlogger.EXPECT().ClosedConnection(qlog.CloseReasonIdleTimeout),
|
qlogger.EXPECT().ClosedConnection(logging.CloseReasonIdleTimeout),
|
||||||
qlogger.EXPECT().Export(),
|
qlogger.EXPECT().Export(),
|
||||||
)
|
)
|
||||||
sess.idleTimeout = 0
|
sess.idleTimeout = 0
|
||||||
|
@ -2195,14 +2195,14 @@ var _ = Describe("Client Session", func() {
|
||||||
|
|
||||||
It("ignores Version Negotiation packets that offer the current version", func() {
|
It("ignores Version Negotiation packets that offer the current version", func() {
|
||||||
p := getVNP(sess.version)
|
p := getVNP(sess.version)
|
||||||
qlogger.EXPECT().DroppedPacket(qlog.PacketTypeVersionNegotiation, protocol.ByteCount(len(p.data)), qlog.PacketDropUnexpectedVersion)
|
qlogger.EXPECT().DroppedPacket(logging.PacketTypeVersionNegotiation, protocol.ByteCount(len(p.data)), logging.PacketDropUnexpectedVersion)
|
||||||
Expect(sess.handlePacketImpl(p)).To(BeFalse())
|
Expect(sess.handlePacketImpl(p)).To(BeFalse())
|
||||||
})
|
})
|
||||||
|
|
||||||
It("ignores unparseable Version Negotiation packets", func() {
|
It("ignores unparseable Version Negotiation packets", func() {
|
||||||
p := getVNP(sess.version)
|
p := getVNP(sess.version)
|
||||||
p.data = p.data[:len(p.data)-2]
|
p.data = p.data[:len(p.data)-2]
|
||||||
qlogger.EXPECT().DroppedPacket(qlog.PacketTypeVersionNegotiation, protocol.ByteCount(len(p.data)), qlog.PacketDropHeaderParseError)
|
qlogger.EXPECT().DroppedPacket(logging.PacketTypeVersionNegotiation, protocol.ByteCount(len(p.data)), logging.PacketDropHeaderParseError)
|
||||||
Expect(sess.handlePacketImpl(p)).To(BeFalse())
|
Expect(sess.handlePacketImpl(p)).To(BeFalse())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -2249,14 +2249,14 @@ var _ = Describe("Client Session", func() {
|
||||||
It("ignores Retry packets after receiving a regular packet", func() {
|
It("ignores Retry packets after receiving a regular packet", func() {
|
||||||
sess.receivedFirstPacket = true
|
sess.receivedFirstPacket = true
|
||||||
p := getPacket(retryHdr, getRetryTag(retryHdr))
|
p := getPacket(retryHdr, getRetryTag(retryHdr))
|
||||||
qlogger.EXPECT().DroppedPacket(qlog.PacketTypeRetry, protocol.ByteCount(len(p.data)), qlog.PacketDropUnexpectedPacket)
|
qlogger.EXPECT().DroppedPacket(logging.PacketTypeRetry, protocol.ByteCount(len(p.data)), logging.PacketDropUnexpectedPacket)
|
||||||
Expect(sess.handlePacketImpl(p)).To(BeFalse())
|
Expect(sess.handlePacketImpl(p)).To(BeFalse())
|
||||||
})
|
})
|
||||||
|
|
||||||
It("ignores Retry packets if the server didn't change the connection ID", func() {
|
It("ignores Retry packets if the server didn't change the connection ID", func() {
|
||||||
retryHdr.SrcConnectionID = destConnID
|
retryHdr.SrcConnectionID = destConnID
|
||||||
p := getPacket(retryHdr, getRetryTag(retryHdr))
|
p := getPacket(retryHdr, getRetryTag(retryHdr))
|
||||||
qlogger.EXPECT().DroppedPacket(qlog.PacketTypeRetry, protocol.ByteCount(len(p.data)), qlog.PacketDropUnexpectedPacket)
|
qlogger.EXPECT().DroppedPacket(logging.PacketTypeRetry, protocol.ByteCount(len(p.data)), logging.PacketDropUnexpectedPacket)
|
||||||
Expect(sess.handlePacketImpl(p)).To(BeFalse())
|
Expect(sess.handlePacketImpl(p)).To(BeFalse())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -2264,7 +2264,7 @@ var _ = Describe("Client Session", func() {
|
||||||
tag := getRetryTag(retryHdr)
|
tag := getRetryTag(retryHdr)
|
||||||
tag[0]++
|
tag[0]++
|
||||||
p := getPacket(retryHdr, tag)
|
p := getPacket(retryHdr, tag)
|
||||||
qlogger.EXPECT().DroppedPacket(qlog.PacketTypeRetry, protocol.ByteCount(len(p.data)), qlog.PacketDropPayloadDecryptError)
|
qlogger.EXPECT().DroppedPacket(logging.PacketTypeRetry, protocol.ByteCount(len(p.data)), logging.PacketDropPayloadDecryptError)
|
||||||
Expect(sess.handlePacketImpl(p)).To(BeFalse())
|
Expect(sess.handlePacketImpl(p)).To(BeFalse())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -2490,7 +2490,7 @@ var _ = Describe("Client Session", func() {
|
||||||
PacketNumber: 0x42,
|
PacketNumber: 0x42,
|
||||||
PacketNumberLen: protocol.PacketNumberLen2,
|
PacketNumberLen: protocol.PacketNumberLen2,
|
||||||
}, []byte("foobar"))
|
}, []byte("foobar"))
|
||||||
qlogger.EXPECT().DroppedPacket(qlog.PacketType0RTT, protocol.ByteCount(len(p.data)), gomock.Any())
|
qlogger.EXPECT().DroppedPacket(logging.PacketType0RTT, protocol.ByteCount(len(p.data)), gomock.Any())
|
||||||
Expect(sess.handlePacketImpl(p)).To(BeFalse())
|
Expect(sess.handlePacketImpl(p)).To(BeFalse())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue