rename qlogger (member) variables to tracer

This commit is contained in:
Marten Seemann 2020-06-29 11:49:03 +07:00
parent 78ba619a0b
commit 7fdace490c
9 changed files with 274 additions and 274 deletions

View file

@ -41,8 +41,8 @@ type client struct {
session quicSession session quicSession
qlogger logging.Tracer tracer logging.Tracer
logger utils.Logger logger utils.Logger
} }
var _ packetHandler = &client{} var _ packetHandler = &client{}
@ -51,8 +51,8 @@ var (
// make it possible to mock connection ID generation in the tests // make it possible to mock connection ID generation in the tests
generateConnectionID = protocol.GenerateConnectionID generateConnectionID = protocol.GenerateConnectionID
generateConnectionIDForInitial = protocol.GenerateConnectionIDForInitial generateConnectionIDForInitial = protocol.GenerateConnectionIDForInitial
// make it possible to the qlogger // make it possible to the tracer
newQlogger = qlog.NewTracer newTracer = qlog.NewTracer
) )
// DialAddr establishes a new QUIC connection to a server. // DialAddr establishes a new QUIC connection to a server.
@ -182,7 +182,7 @@ func dialContext(
if c.config.GetLogWriter != nil { if c.config.GetLogWriter != nil {
if w := c.config.GetLogWriter(c.destConnID); w != nil { if w := c.config.GetLogWriter(c.destConnID); w != nil {
c.qlogger = newQlogger(w, protocol.PerspectiveClient, c.destConnID) c.tracer = newTracer(w, protocol.PerspectiveClient, c.destConnID)
} }
} }
if err := c.dial(ctx); err != nil { if err := c.dial(ctx); err != nil {
@ -250,8 +250,8 @@ func newClient(
func (c *client) dial(ctx context.Context) error { func (c *client) dial(ctx context.Context) error {
c.logger.Infof("Starting new connection to %s (%s -> %s), source connection ID %s, destination connection ID %s, version %s", c.tlsConf.ServerName, c.conn.LocalAddr(), c.conn.RemoteAddr(), c.srcConnID, c.destConnID, c.version) c.logger.Infof("Starting new connection to %s (%s -> %s), source connection ID %s, destination connection ID %s, version %s", c.tlsConf.ServerName, c.conn.LocalAddr(), c.conn.RemoteAddr(), c.srcConnID, c.destConnID, c.version)
if c.qlogger != nil { if c.tracer != nil {
c.qlogger.StartedConnection(c.conn.LocalAddr(), c.conn.RemoteAddr(), c.version, c.srcConnID, c.destConnID) c.tracer.StartedConnection(c.conn.LocalAddr(), c.conn.RemoteAddr(), c.version, c.srcConnID, c.destConnID)
} }
c.mutex.Lock() c.mutex.Lock()
@ -266,7 +266,7 @@ func (c *client) dial(ctx context.Context) error {
c.version, c.version,
c.use0RTT, c.use0RTT,
c.hasNegotiatedVersion, c.hasNegotiatedVersion,
c.qlogger, c.tracer,
c.logger, c.logger,
c.version, c.version,
) )

View file

@ -34,7 +34,7 @@ var _ = Describe("Client", func() {
mockMultiplexer *MockMultiplexer mockMultiplexer *MockMultiplexer
origMultiplexer multiplexer origMultiplexer multiplexer
tlsConf *tls.Config tlsConf *tls.Config
qlogger *mocks.MockTracer tracer *mocks.MockTracer
config *Config config *Config
originalClientSessConstructor func( originalClientSessConstructor func(
@ -48,11 +48,11 @@ var _ = Describe("Client", func() {
initialVersion protocol.VersionNumber, initialVersion protocol.VersionNumber,
enable0RTT bool, enable0RTT bool,
hasNegotiatedVersion bool, hasNegotiatedVersion bool,
qlogger logging.Tracer, tracer logging.Tracer,
logger utils.Logger, logger utils.Logger,
v protocol.VersionNumber, v protocol.VersionNumber,
) quicSession ) quicSession
originalQlogConstructor func(io.WriteCloser, protocol.Perspective, protocol.ConnectionID) logging.Tracer originalTracerConstructor 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
@ -70,14 +70,14 @@ var _ = Describe("Client", func() {
tlsConf = &tls.Config{NextProtos: []string{"proto1"}} tlsConf = &tls.Config{NextProtos: []string{"proto1"}}
connID = protocol.ConnectionID{0, 0, 0, 0, 0, 0, 0x13, 0x37} connID = protocol.ConnectionID{0, 0, 0, 0, 0, 0, 0x13, 0x37}
originalClientSessConstructor = newClientSession originalClientSessConstructor = newClientSession
originalQlogConstructor = newQlogger originalTracerConstructor = newTracer
qlogger = mocks.NewMockTracer(mockCtrl) tracer = mocks.NewMockTracer(mockCtrl)
newQlogger = func(io.WriteCloser, protocol.Perspective, protocol.ConnectionID) logging.Tracer { newTracer = func(io.WriteCloser, protocol.Perspective, protocol.ConnectionID) logging.Tracer {
return qlogger return tracer
} }
config = &Config{ config = &Config{
GetLogWriter: func([]byte) io.WriteCloser { GetLogWriter: func([]byte) io.WriteCloser {
// Since we're mocking the qlogger, it doesn't matter what we return here, // Since we're mocking the tracer, it doesn't matter what we return here,
// as long as it's not nil. // as long as it's not nil.
return utils.NewBufferedWriteCloser( return utils.NewBufferedWriteCloser(
bufio.NewWriter(&bytes.Buffer{}), bufio.NewWriter(&bytes.Buffer{}),
@ -96,7 +96,7 @@ var _ = Describe("Client", func() {
destConnID: connID, destConnID: connID,
version: protocol.SupportedVersions[0], version: protocol.SupportedVersions[0],
conn: &conn{pconn: packetConn, currentAddr: addr}, conn: &conn{pconn: packetConn, currentAddr: addr},
qlogger: qlogger, tracer: tracer,
logger: utils.DefaultLogger, logger: utils.DefaultLogger,
} }
getMultiplexer() // make the sync.Once execute getMultiplexer() // make the sync.Once execute
@ -109,7 +109,7 @@ var _ = Describe("Client", func() {
AfterEach(func() { AfterEach(func() {
connMuxer = origMultiplexer connMuxer = origMultiplexer
newClientSession = originalClientSessConstructor newClientSession = originalClientSessConstructor
newQlogger = originalQlogConstructor newTracer = originalTracerConstructor
}) })
AfterEach(func() { AfterEach(func() {
@ -237,7 +237,7 @@ var _ = Describe("Client", func() {
sess.EXPECT().run() sess.EXPECT().run()
return sess return sess
} }
qlogger.EXPECT().StartedConnection(packetConn.addr, addr, protocol.VersionTLS, gomock.Any(), gomock.Any()) tracer.EXPECT().StartedConnection(packetConn.addr, addr, protocol.VersionTLS, gomock.Any(), gomock.Any())
_, err := Dial( _, err := Dial(
packetConn, packetConn,
addr, addr,
@ -278,7 +278,7 @@ var _ = Describe("Client", func() {
sess.EXPECT().HandshakeComplete().Return(ctx) sess.EXPECT().HandshakeComplete().Return(ctx)
return sess return sess
} }
qlogger.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), protocol.VersionTLS, gomock.Any(), gomock.Any()) tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), protocol.VersionTLS, gomock.Any(), gomock.Any())
s, err := Dial( s, err := Dial(
packetConn, packetConn,
addr, addr,
@ -324,7 +324,7 @@ var _ = Describe("Client", func() {
go func() { go func() {
defer GinkgoRecover() defer GinkgoRecover()
defer close(done) defer close(done)
qlogger.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), protocol.VersionTLS, gomock.Any(), gomock.Any()) tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), protocol.VersionTLS, gomock.Any(), gomock.Any())
s, err := DialEarly( s, err := DialEarly(
packetConn, packetConn,
addr, addr,
@ -367,7 +367,7 @@ var _ = Describe("Client", func() {
return sess return sess
} }
packetConn.dataToRead <- acceptClientVersionPacket(cl.srcConnID) packetConn.dataToRead <- acceptClientVersionPacket(cl.srcConnID)
qlogger.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), protocol.VersionTLS, gomock.Any(), gomock.Any()) tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), protocol.VersionTLS, gomock.Any(), gomock.Any())
_, err := Dial( _, err := Dial(
packetConn, packetConn,
addr, addr,
@ -411,7 +411,7 @@ var _ = Describe("Client", func() {
dialed := make(chan struct{}) dialed := make(chan struct{})
go func() { go func() {
defer GinkgoRecover() defer GinkgoRecover()
qlogger.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), protocol.VersionTLS, gomock.Any(), gomock.Any()) tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), protocol.VersionTLS, gomock.Any(), gomock.Any())
_, err := DialContext( _, err := DialContext(
ctx, ctx,
packetConn, packetConn,
@ -642,8 +642,8 @@ var _ = Describe("Client", func() {
} }
gomock.InOrder( gomock.InOrder(
qlogger.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), initialVersion, gomock.Any(), gomock.Any()), tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), initialVersion, gomock.Any(), gomock.Any()),
qlogger.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), protocol.VersionNumber(789), gomock.Any(), gomock.Any()), tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), protocol.VersionNumber(789), gomock.Any(), gomock.Any()),
) )
_, err := DialAddr("localhost:7890", tlsConf, config) _, err := DialAddr("localhost:7890", tlsConf, config)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())

View file

@ -14,10 +14,10 @@ func NewAckHandler(
rttStats *congestion.RTTStats, rttStats *congestion.RTTStats,
pers protocol.Perspective, pers protocol.Perspective,
traceCallback func(quictrace.Event), traceCallback func(quictrace.Event),
qlogger logging.Tracer, tracer logging.Tracer,
logger utils.Logger, logger utils.Logger,
version protocol.VersionNumber, version protocol.VersionNumber,
) (SentPacketHandler, ReceivedPacketHandler) { ) (SentPacketHandler, ReceivedPacketHandler) {
sph := newSentPacketHandler(initialPacketNumber, rttStats, pers, traceCallback, qlogger, logger) sph := newSentPacketHandler(initialPacketNumber, rttStats, pers, traceCallback, tracer, logger)
return sph, newReceivedPacketHandler(sph, rttStats, logger, version) return sph, newReceivedPacketHandler(sph, rttStats, logger, version)
} }

View file

@ -84,7 +84,7 @@ type sentPacketHandler struct {
perspective protocol.Perspective perspective protocol.Perspective
traceCallback func(quictrace.Event) traceCallback func(quictrace.Event)
qlogger logging.Tracer tracer 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 logging.Tracer, tracer logging.Tracer,
logger utils.Logger, logger utils.Logger,
) *sentPacketHandler { ) *sentPacketHandler {
congestion := congestion.NewCubicSender( congestion := congestion.NewCubicSender(
@ -115,7 +115,7 @@ func newSentPacketHandler(
congestion: congestion, congestion: congestion,
perspective: pers, perspective: pers,
traceCallback: traceCallback, traceCallback: traceCallback,
qlogger: qlogger, tracer: tracer,
logger: logger, logger: logger,
} }
} }
@ -169,8 +169,8 @@ func (h *sentPacketHandler) dropPackets(encLevel protocol.EncryptionLevel) {
panic(fmt.Sprintf("Cannot drop keys for encryption level %s", encLevel)) panic(fmt.Sprintf("Cannot drop keys for encryption level %s", encLevel))
} }
h.setLossDetectionTimer() h.setLossDetectionTimer()
if h.qlogger != nil && h.ptoCount != 0 { if h.tracer != nil && h.ptoCount != 0 {
h.qlogger.UpdatedPTOCount(0) h.tracer.UpdatedPTOCount(0)
} }
h.ptoCount = 0 h.ptoCount = 0
h.numProbesToSend = 0 h.numProbesToSend = 0
@ -208,8 +208,8 @@ func (h *sentPacketHandler) SentPacket(packet *Packet) {
if isAckEliciting { if isAckEliciting {
h.getPacketNumberSpace(packet.EncryptionLevel).history.SentPacket(packet) h.getPacketNumberSpace(packet.EncryptionLevel).history.SentPacket(packet)
} }
if h.qlogger != nil && isAckEliciting { if h.tracer != nil && isAckEliciting {
h.qlogger.UpdatedMetrics(h.rttStats, h.congestion.GetCongestionWindow(), h.bytesInFlight, h.packetsInFlight()) h.tracer.UpdatedMetrics(h.rttStats, h.congestion.GetCongestionWindow(), h.bytesInFlight, h.packetsInFlight())
} }
if isAckEliciting || !h.peerCompletedAddressValidation { if isAckEliciting || !h.peerCompletedAddressValidation {
h.setLossDetectionTimer() h.setLossDetectionTimer()
@ -289,8 +289,8 @@ func (h *sentPacketHandler) ReceivedAck(ack *wire.AckFrame, encLevel protocol.En
h.logger.Debugf("\tupdated RTT: %s (σ: %s)", h.rttStats.SmoothedRTT(), h.rttStats.MeanDeviation()) h.logger.Debugf("\tupdated RTT: %s (σ: %s)", h.rttStats.SmoothedRTT(), h.rttStats.MeanDeviation())
} }
h.congestion.MaybeExitSlowStart() h.congestion.MaybeExitSlowStart()
if h.qlogger != nil { if h.tracer != nil {
h.qlogger.UpdatedMetrics(h.rttStats, h.congestion.GetCongestionWindow(), h.bytesInFlight, h.packetsInFlight()) h.tracer.UpdatedMetrics(h.rttStats, h.congestion.GetCongestionWindow(), h.bytesInFlight, h.packetsInFlight())
} }
} }
@ -314,8 +314,8 @@ func (h *sentPacketHandler) ReceivedAck(ack *wire.AckFrame, encLevel protocol.En
// Reset the pto_count unless the client is unsure if the server has validated the client's address. // Reset the pto_count unless the client is unsure if the server has validated the client's address.
if h.peerCompletedAddressValidation { if h.peerCompletedAddressValidation {
if h.qlogger != nil && h.ptoCount != 0 { if h.tracer != nil && h.ptoCount != 0 {
h.qlogger.UpdatedPTOCount(0) h.tracer.UpdatedPTOCount(0)
} }
h.ptoCount = 0 h.ptoCount = 0
} }
@ -472,12 +472,12 @@ func (h *sentPacketHandler) hasOutstandingPackets() bool {
} }
func (h *sentPacketHandler) setLossDetectionTimer() { func (h *sentPacketHandler) setLossDetectionTimer() {
oldAlarm := h.alarm // only needed in case qlog is enabled oldAlarm := h.alarm // only needed in case tracing is enabled
if lossTime, encLevel := h.getLossTimeAndSpace(); !lossTime.IsZero() { if lossTime, encLevel := h.getLossTimeAndSpace(); !lossTime.IsZero() {
// 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.tracer != nil && h.alarm != oldAlarm {
h.qlogger.SetLossTimer(logging.TimerTypeACK, encLevel, h.alarm) h.tracer.SetLossTimer(logging.TimerTypeACK, encLevel, h.alarm)
} }
return return
} }
@ -486,8 +486,8 @@ func (h *sentPacketHandler) setLossDetectionTimer() {
if !h.hasOutstandingPackets() && h.peerCompletedAddressValidation { if !h.hasOutstandingPackets() && h.peerCompletedAddressValidation {
h.alarm = time.Time{} h.alarm = time.Time{}
h.logger.Debugf("Canceling loss detection timer. No packets in flight.") h.logger.Debugf("Canceling loss detection timer. No packets in flight.")
if h.qlogger != nil && !oldAlarm.IsZero() { if h.tracer != nil && !oldAlarm.IsZero() {
h.qlogger.LossTimerCanceled() h.tracer.LossTimerCanceled()
} }
return return
} }
@ -495,8 +495,8 @@ func (h *sentPacketHandler) setLossDetectionTimer() {
// PTO alarm // PTO alarm
ptoTime, encLevel := h.getPTOTimeAndSpace() ptoTime, encLevel := h.getPTOTimeAndSpace()
h.alarm = ptoTime h.alarm = ptoTime
if h.qlogger != nil && h.alarm != oldAlarm { if h.tracer != nil && h.alarm != oldAlarm {
h.qlogger.SetLossTimer(logging.TimerTypePTO, encLevel, h.alarm) h.tracer.SetLossTimer(logging.TimerTypePTO, encLevel, h.alarm)
} }
} }
@ -521,13 +521,13 @@ 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.tracer != nil {
h.qlogger.LostPacket(packet.EncryptionLevel, packet.PacketNumber, logging.PacketLossTimeThreshold) h.tracer.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.tracer != nil {
h.qlogger.LostPacket(packet.EncryptionLevel, packet.PacketNumber, logging.PacketLossReorderingThreshold) h.tracer.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
@ -598,8 +598,8 @@ func (h *sentPacketHandler) onVerifiedLossDetectionTimeout() error {
if h.logger.Debug() { if h.logger.Debug() {
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.tracer != nil {
h.qlogger.LossTimerExpired(logging.TimerTypeACK, encLevel) h.tracer.LossTimerExpired(logging.TimerTypeACK, encLevel)
} }
// Early retransmit or time loss detection // Early retransmit or time loss detection
priorInFlight := h.bytesInFlight priorInFlight := h.bytesInFlight
@ -620,9 +620,9 @@ func (h *sentPacketHandler) onVerifiedLossDetectionTimeout() error {
if h.logger.Debug() { if h.logger.Debug() {
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.tracer != nil {
h.qlogger.LossTimerExpired(logging.TimerTypePTO, encLevel) h.tracer.LossTimerExpired(logging.TimerTypePTO, encLevel)
h.qlogger.UpdatedPTOCount(h.ptoCount) h.tracer.UpdatedPTOCount(h.ptoCount)
} }
h.numProbesToSend += 2 h.numProbesToSend += 2
switch encLevel { switch encLevel {
@ -783,18 +783,18 @@ func (h *sentPacketHandler) ResetForRetry() error {
if h.logger.Debug() { if h.logger.Debug() {
h.logger.Debugf("\tupdated RTT: %s (σ: %s)", h.rttStats.SmoothedRTT(), h.rttStats.MeanDeviation()) h.logger.Debugf("\tupdated RTT: %s (σ: %s)", h.rttStats.SmoothedRTT(), h.rttStats.MeanDeviation())
} }
if h.qlogger != nil { if h.tracer != nil {
h.qlogger.UpdatedMetrics(h.rttStats, h.congestion.GetCongestionWindow(), h.bytesInFlight, h.packetsInFlight()) h.tracer.UpdatedMetrics(h.rttStats, h.congestion.GetCongestionWindow(), h.bytesInFlight, h.packetsInFlight())
} }
} }
h.initialPackets = newPacketNumberSpace(h.initialPackets.pns.Pop()) h.initialPackets = newPacketNumberSpace(h.initialPackets.pns.Pop())
h.appDataPackets = newPacketNumberSpace(h.appDataPackets.pns.Pop()) h.appDataPackets = newPacketNumberSpace(h.appDataPackets.pns.Pop())
oldAlarm := h.alarm oldAlarm := h.alarm
h.alarm = time.Time{} h.alarm = time.Time{}
if h.qlogger != nil { if h.tracer != nil {
h.qlogger.UpdatedPTOCount(0) h.tracer.UpdatedPTOCount(0)
if !oldAlarm.IsZero() { if !oldAlarm.IsZero() {
h.qlogger.LossTimerCanceled() h.tracer.LossTimerCanceled()
} }
} }
h.ptoCount = 0 h.ptoCount = 0

View file

@ -94,8 +94,8 @@ type cryptoSetup struct {
rttStats *congestion.RTTStats rttStats *congestion.RTTStats
qlogger logging.Tracer tracer 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 logging.Tracer, tracer 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(
@ -149,7 +149,7 @@ func NewCryptoSetupClient(
tlsConf, tlsConf,
enable0RTT, enable0RTT,
rttStats, rttStats,
qlogger, tracer,
logger, logger,
protocol.PerspectiveClient, protocol.PerspectiveClient,
) )
@ -169,7 +169,7 @@ func NewCryptoSetupServer(
tlsConf *tls.Config, tlsConf *tls.Config,
enable0RTT bool, enable0RTT bool,
rttStats *congestion.RTTStats, rttStats *congestion.RTTStats,
qlogger logging.Tracer, tracer logging.Tracer,
logger utils.Logger, logger utils.Logger,
) CryptoSetup { ) CryptoSetup {
cs, _ := newCryptoSetup( cs, _ := newCryptoSetup(
@ -181,7 +181,7 @@ func NewCryptoSetupServer(
tlsConf, tlsConf,
enable0RTT, enable0RTT,
rttStats, rttStats,
qlogger, tracer,
logger, logger,
protocol.PerspectiveServer, protocol.PerspectiveServer,
) )
@ -198,14 +198,14 @@ func newCryptoSetup(
tlsConf *tls.Config, tlsConf *tls.Config,
enable0RTT bool, enable0RTT bool,
rttStats *congestion.RTTStats, rttStats *congestion.RTTStats,
qlogger logging.Tracer, tracer 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 */) {
initialSealer, initialOpener := NewInitialAEAD(connID, perspective) initialSealer, initialOpener := NewInitialAEAD(connID, perspective)
if qlogger != nil { if tracer != nil {
qlogger.UpdatedKeyFromTLS(protocol.EncryptionInitial, protocol.PerspectiveClient) tracer.UpdatedKeyFromTLS(protocol.EncryptionInitial, protocol.PerspectiveClient)
qlogger.UpdatedKeyFromTLS(protocol.EncryptionInitial, protocol.PerspectiveServer) tracer.UpdatedKeyFromTLS(protocol.EncryptionInitial, protocol.PerspectiveServer)
} }
extHandler := newExtensionHandler(tp.Marshal(perspective), perspective) extHandler := newExtensionHandler(tp.Marshal(perspective), perspective)
cs := &cryptoSetup{ cs := &cryptoSetup{
@ -213,14 +213,14 @@ func newCryptoSetup(
initialSealer: initialSealer, initialSealer: initialSealer,
initialOpener: initialOpener, initialOpener: initialOpener,
handshakeStream: handshakeStream, handshakeStream: handshakeStream,
aead: newUpdatableAEAD(rttStats, qlogger, logger), aead: newUpdatableAEAD(rttStats, tracer, logger),
readEncLevel: protocol.EncryptionInitial, readEncLevel: protocol.EncryptionInitial,
writeEncLevel: protocol.EncryptionInitial, writeEncLevel: protocol.EncryptionInitial,
runner: runner, runner: runner,
ourParams: tp, ourParams: tp,
paramsChan: extHandler.TransportParameters(), paramsChan: extHandler.TransportParameters(),
rttStats: rttStats, rttStats: rttStats,
qlogger: qlogger, tracer: tracer,
logger: logger, logger: logger,
perspective: perspective, perspective: perspective,
handshakeDone: make(chan struct{}), handshakeDone: make(chan struct{}),
@ -241,9 +241,9 @@ func (h *cryptoSetup) ChangeConnectionID(id protocol.ConnectionID) {
initialSealer, initialOpener := NewInitialAEAD(id, h.perspective) initialSealer, initialOpener := NewInitialAEAD(id, h.perspective)
h.initialSealer = initialSealer h.initialSealer = initialSealer
h.initialOpener = initialOpener h.initialOpener = initialOpener
if h.qlogger != nil { if h.tracer != nil {
h.qlogger.UpdatedKeyFromTLS(protocol.EncryptionInitial, protocol.PerspectiveClient) h.tracer.UpdatedKeyFromTLS(protocol.EncryptionInitial, protocol.PerspectiveClient)
h.qlogger.UpdatedKeyFromTLS(protocol.EncryptionInitial, protocol.PerspectiveServer) h.tracer.UpdatedKeyFromTLS(protocol.EncryptionInitial, protocol.PerspectiveServer)
} }
} }
@ -589,8 +589,8 @@ func (h *cryptoSetup) SetReadKey(encLevel qtls.EncryptionLevel, suite *qtls.Ciph
) )
h.mutex.Unlock() h.mutex.Unlock()
h.logger.Debugf("Installed 0-RTT Read keys (using %s)", qtls.CipherSuiteName(suite.ID)) h.logger.Debugf("Installed 0-RTT Read keys (using %s)", qtls.CipherSuiteName(suite.ID))
if h.qlogger != nil { if h.tracer != nil {
h.qlogger.UpdatedKeyFromTLS(protocol.Encryption0RTT, h.perspective.Opposite()) h.tracer.UpdatedKeyFromTLS(protocol.Encryption0RTT, h.perspective.Opposite())
} }
return return
case qtls.EncryptionHandshake: case qtls.EncryptionHandshake:
@ -611,8 +611,8 @@ func (h *cryptoSetup) SetReadKey(encLevel qtls.EncryptionLevel, suite *qtls.Ciph
panic("unexpected read encryption level") panic("unexpected read encryption level")
} }
h.mutex.Unlock() h.mutex.Unlock()
if h.qlogger != nil { if h.tracer != nil {
h.qlogger.UpdatedKeyFromTLS(h.readEncLevel, h.perspective.Opposite()) h.tracer.UpdatedKeyFromTLS(h.readEncLevel, h.perspective.Opposite())
} }
h.receivedReadKey <- struct{}{} h.receivedReadKey <- struct{}{}
} }
@ -630,8 +630,8 @@ func (h *cryptoSetup) SetWriteKey(encLevel qtls.EncryptionLevel, suite *qtls.Cip
) )
h.mutex.Unlock() h.mutex.Unlock()
h.logger.Debugf("Installed 0-RTT Write keys (using %s)", qtls.CipherSuiteName(suite.ID)) h.logger.Debugf("Installed 0-RTT Write keys (using %s)", qtls.CipherSuiteName(suite.ID))
if h.qlogger != nil { if h.tracer != nil {
h.qlogger.UpdatedKeyFromTLS(protocol.Encryption0RTT, h.perspective) h.tracer.UpdatedKeyFromTLS(protocol.Encryption0RTT, h.perspective)
} }
return return
case qtls.EncryptionHandshake: case qtls.EncryptionHandshake:
@ -656,8 +656,8 @@ func (h *cryptoSetup) SetWriteKey(encLevel qtls.EncryptionLevel, suite *qtls.Cip
panic("unexpected write encryption level") panic("unexpected write encryption level")
} }
h.mutex.Unlock() h.mutex.Unlock()
if h.qlogger != nil { if h.tracer != nil {
h.qlogger.UpdatedKeyFromTLS(h.writeEncLevel, h.perspective) h.tracer.UpdatedKeyFromTLS(h.writeEncLevel, h.perspective)
} }
h.receivedWriteKey <- struct{}{} h.receivedWriteKey <- struct{}{}
} }

View file

@ -74,8 +74,8 @@ type updatableAEAD struct {
rttStats *congestion.RTTStats rttStats *congestion.RTTStats
qlogger logging.Tracer tracer logging.Tracer
logger utils.Logger logger utils.Logger
// use a single slice to avoid allocations // use a single slice to avoid allocations
nonceBuf []byte nonceBuf []byte
@ -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 logging.Tracer, logger utils.Logger) *updatableAEAD { func newUpdatableAEAD(rttStats *congestion.RTTStats, tracer logging.Tracer, logger utils.Logger) *updatableAEAD {
return &updatableAEAD{ return &updatableAEAD{
firstPacketNumber: protocol.InvalidPacketNumber, firstPacketNumber: protocol.InvalidPacketNumber,
largestAcked: protocol.InvalidPacketNumber, largestAcked: protocol.InvalidPacketNumber,
@ -92,7 +92,7 @@ func newUpdatableAEAD(rttStats *congestion.RTTStats, qlogger logging.Tracer, log
firstSentWithCurrentKey: protocol.InvalidPacketNumber, firstSentWithCurrentKey: protocol.InvalidPacketNumber,
keyUpdateInterval: keyUpdateInterval, keyUpdateInterval: keyUpdateInterval,
rttStats: rttStats, rttStats: rttStats,
qlogger: qlogger, tracer: tracer,
logger: logger, logger: logger,
} }
} }
@ -183,8 +183,8 @@ func (a *updatableAEAD) Open(dst, src []byte, rcvTime time.Time, pn protocol.Pac
} }
a.rollKeys(rcvTime) a.rollKeys(rcvTime)
a.logger.Debugf("Peer updated keys to %s", a.keyPhase) a.logger.Debugf("Peer updated keys to %s", a.keyPhase)
if a.qlogger != nil { if a.tracer != nil {
a.qlogger.UpdatedKey(a.keyPhase, true) a.tracer.UpdatedKey(a.keyPhase, true)
} }
a.firstRcvdWithCurrentKey = pn a.firstRcvdWithCurrentKey = pn
return dec, err return dec, err
@ -244,8 +244,8 @@ func (a *updatableAEAD) shouldInitiateKeyUpdate() bool {
func (a *updatableAEAD) KeyPhase() protocol.KeyPhaseBit { func (a *updatableAEAD) KeyPhase() protocol.KeyPhaseBit {
if a.shouldInitiateKeyUpdate() { if a.shouldInitiateKeyUpdate() {
if a.qlogger != nil { if a.tracer != nil {
a.qlogger.UpdatedKey(a.keyPhase, false) a.tracer.UpdatedKey(a.keyPhase, false)
} }
a.rollKeys(time.Now()) a.rollKeys(time.Now())
} }

View file

@ -447,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 logging.Tracer var tracer 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
@ -455,7 +455,7 @@ func (s *baseServer) createNewSession(
connID = origDestConnID connID = origDestConnID
} }
if w := s.config.GetLogWriter(connID); w != nil { if w := s.config.GetLogWriter(connID); w != nil {
qlogger = qlog.NewTracer(w, protocol.PerspectiveServer, connID) tracer = qlog.NewTracer(w, protocol.PerspectiveServer, connID)
} }
} }
sess = s.newSession( sess = s.newSession(
@ -471,7 +471,7 @@ func (s *baseServer) createNewSession(
s.tlsConf, s.tlsConf,
s.tokenGenerator, s.tokenGenerator,
s.acceptEarlySessions, s.acceptEarlySessions,
qlogger, tracer,
s.logger, s.logger,
version, version,
) )

View file

@ -203,9 +203,9 @@ type session struct {
traceCallback func(quictrace.Event) traceCallback func(quictrace.Event)
logID string logID string
qlogger logging.Tracer tracer logging.Tracer
logger utils.Logger logger utils.Logger
} }
var _ Session = &session{} var _ Session = &session{}
@ -225,7 +225,7 @@ var newSession = func(
tlsConf *tls.Config, tlsConf *tls.Config,
tokenGenerator *handshake.TokenGenerator, tokenGenerator *handshake.TokenGenerator,
enable0RTT bool, enable0RTT bool,
qlogger logging.Tracer, tracer logging.Tracer,
logger utils.Logger, logger utils.Logger,
v protocol.VersionNumber, v protocol.VersionNumber,
) quicSession { ) quicSession {
@ -238,7 +238,7 @@ var newSession = func(
oneRTTStream: newCryptoStream(), oneRTTStream: newCryptoStream(),
perspective: protocol.PerspectiveServer, perspective: protocol.PerspectiveServer,
handshakeCompleteChan: make(chan struct{}), handshakeCompleteChan: make(chan struct{}),
qlogger: qlogger, tracer: tracer,
logger: logger, logger: logger,
version: v, version: v,
} }
@ -270,7 +270,7 @@ var newSession = func(
s.rttStats, s.rttStats,
s.perspective, s.perspective,
s.traceCallback, s.traceCallback,
s.qlogger, s.tracer,
s.logger, s.logger,
s.version, s.version,
) )
@ -293,8 +293,8 @@ var newSession = func(
InitialSourceConnectionID: srcConnID, InitialSourceConnectionID: srcConnID,
RetrySourceConnectionID: retrySrcConnID, RetrySourceConnectionID: retrySrcConnID,
} }
if s.qlogger != nil { if s.tracer != nil {
s.qlogger.SentTransportParameters(params) s.tracer.SentTransportParameters(params)
} }
cs := handshake.NewCryptoSetupServer( cs := handshake.NewCryptoSetupServer(
initialStream, initialStream,
@ -315,7 +315,7 @@ var newSession = func(
tlsConf, tlsConf,
enable0RTT, enable0RTT,
s.rttStats, s.rttStats,
qlogger, tracer,
logger, logger,
) )
s.cryptoStreamHandler = cs s.cryptoStreamHandler = cs
@ -350,7 +350,7 @@ var newClientSession = func(
initialVersion protocol.VersionNumber, initialVersion protocol.VersionNumber,
enable0RTT bool, enable0RTT bool,
hasNegotiatedVersion bool, hasNegotiatedVersion bool,
qlogger logging.Tracer, tracer logging.Tracer,
logger utils.Logger, logger utils.Logger,
v protocol.VersionNumber, v protocol.VersionNumber,
) quicSession { ) quicSession {
@ -364,7 +364,7 @@ var newClientSession = func(
handshakeCompleteChan: make(chan struct{}), handshakeCompleteChan: make(chan struct{}),
logID: destConnID.String(), logID: destConnID.String(),
logger: logger, logger: logger,
qlogger: qlogger, tracer: tracer,
initialVersion: initialVersion, initialVersion: initialVersion,
versionNegotiated: hasNegotiatedVersion, versionNegotiated: hasNegotiatedVersion,
version: v, version: v,
@ -392,7 +392,7 @@ var newClientSession = func(
s.rttStats, s.rttStats,
s.perspective, s.perspective,
s.traceCallback, s.traceCallback,
s.qlogger, s.tracer,
s.logger, s.logger,
s.version, s.version,
) )
@ -412,8 +412,8 @@ var newClientSession = func(
ActiveConnectionIDLimit: protocol.MaxActiveConnectionIDs, ActiveConnectionIDLimit: protocol.MaxActiveConnectionIDs,
InitialSourceConnectionID: srcConnID, InitialSourceConnectionID: srcConnID,
} }
if s.qlogger != nil { if s.tracer != nil {
s.qlogger.SentTransportParameters(params) s.tracer.SentTransportParameters(params)
} }
cs, clientHelloWritten := handshake.NewCryptoSetupClient( cs, clientHelloWritten := handshake.NewCryptoSetupClient(
initialStream, initialStream,
@ -431,7 +431,7 @@ var newClientSession = func(
tlsConf, tlsConf,
enable0RTT, enable0RTT,
s.rttStats, s.rttStats,
qlogger, tracer,
logger, logger,
) )
s.clientHelloWritten = clientHelloWritten s.clientHelloWritten = clientHelloWritten
@ -591,14 +591,14 @@ runLoop:
s.framer.QueueControlFrame(&wire.PingFrame{}) s.framer.QueueControlFrame(&wire.PingFrame{})
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.tracer != nil {
s.qlogger.ClosedConnection(logging.CloseReasonHandshakeTimeout) s.tracer.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.tracer != nil {
s.qlogger.ClosedConnection(logging.CloseReasonIdleTimeout) s.tracer.ClosedConnection(logging.CloseReasonIdleTimeout)
} }
s.destroyImpl(qerr.NewTimeoutError("No recent network activity")) s.destroyImpl(qerr.NewTimeoutError("No recent network activity"))
continue continue
@ -610,8 +610,8 @@ runLoop:
} }
s.handleCloseError(closeErr) s.handleCloseError(closeErr)
if !errors.Is(closeErr.err, errCloseForRecreating{}) && s.qlogger != nil { if !errors.Is(closeErr.err, errCloseForRecreating{}) && s.tracer != nil {
if err := s.qlogger.Export(); err != nil { if err := s.tracer.Export(); err != nil {
s.logger.Errorf("exporting qlog failed: %s", err) s.logger.Errorf("exporting qlog failed: %s", err)
} }
} }
@ -726,28 +726,28 @@ 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.tracer != nil {
dropReason := logging.PacketDropHeaderParseError dropReason := logging.PacketDropHeaderParseError
if err == wire.ErrUnsupportedVersion { if err == wire.ErrUnsupportedVersion {
dropReason = logging.PacketDropUnsupportedVersion dropReason = logging.PacketDropUnsupportedVersion
} }
s.qlogger.DroppedPacket(logging.PacketTypeNotDetermined, protocol.ByteCount(len(data)), dropReason) s.tracer.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
} }
if hdr.IsLongHeader && hdr.Version != s.version { if hdr.IsLongHeader && hdr.Version != s.version {
if s.qlogger != nil { if s.tracer != nil {
s.qlogger.DroppedPacket(logging.PacketTypeFromHeader(hdr), protocol.ByteCount(len(data)), logging.PacketDropUnexpectedVersion) s.tracer.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
} }
if counter > 0 && !hdr.DestConnectionID.Equal(lastConnID) { if counter > 0 && !hdr.DestConnectionID.Equal(lastConnID) {
if s.qlogger != nil { if s.tracer != nil {
s.qlogger.DroppedPacket(logging.PacketTypeFromHeader(hdr), protocol.ByteCount(len(data)), logging.PacketDropUnknownConnectionID) s.tracer.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
@ -790,15 +790,15 @@ func (s *session) handleSinglePacket(p *receivedPacket, hdr *wire.Header) bool /
// The server can change the source connection ID with the first Handshake packet. // The server can change the source connection ID with the first Handshake packet.
// 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.tracer != nil {
s.qlogger.DroppedPacket(logging.PacketTypeFromHeader(hdr), protocol.ByteCount(len(p.data)), logging.PacketDropUnknownConnectionID) s.tracer.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(logging.PacketType0RTT, protocol.ByteCount(len(p.data)), logging.PacketDropKeyUnavailable) s.tracer.DroppedPacket(logging.PacketType0RTT, protocol.ByteCount(len(p.data)), logging.PacketDropKeyUnavailable)
return false return false
} }
@ -806,8 +806,8 @@ func (s *session) handleSinglePacket(p *receivedPacket, hdr *wire.Header) bool /
if err != nil { if err != nil {
switch err { switch err {
case handshake.ErrKeysDropped: case handshake.ErrKeysDropped:
if s.qlogger != nil { if s.tracer != nil {
s.qlogger.DroppedPacket(logging.PacketTypeFromHeader(hdr), protocol.ByteCount(len(p.data)), logging.PacketDropKeyUnavailable) s.tracer.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:
@ -820,8 +820,8 @@ func (s *session) handleSinglePacket(p *receivedPacket, hdr *wire.Header) bool /
default: default:
// 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.tracer != nil {
s.qlogger.DroppedPacket(logging.PacketTypeFromHeader(hdr), protocol.ByteCount(len(p.data)), logging.PacketDropPayloadDecryptError) s.tracer.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)
} }
@ -835,8 +835,8 @@ 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.tracer != nil {
s.qlogger.DroppedPacket(logging.PacketTypeFromHeader(hdr), protocol.ByteCount(len(p.data)), logging.PacketDropDuplicate) s.tracer.DroppedPacket(logging.PacketTypeFromHeader(hdr), protocol.ByteCount(len(p.data)), logging.PacketDropDuplicate)
} }
return false return false
} }
@ -851,23 +851,23 @@ func (s *session) handleSinglePacket(p *receivedPacket, hdr *wire.Header) bool /
func (s *session) handleRetryPacket(hdr *wire.Header, data []byte) bool /* was this a valid Retry */ { func (s *session) handleRetryPacket(hdr *wire.Header, data []byte) bool /* was this a valid Retry */ {
(&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.tracer != nil {
s.qlogger.DroppedPacket(logging.PacketTypeRetry, protocol.ByteCount(len(data)), logging.PacketDropUnexpectedPacket) s.tracer.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.tracer != nil {
s.qlogger.DroppedPacket(logging.PacketTypeRetry, protocol.ByteCount(len(data)), logging.PacketDropUnexpectedPacket) s.tracer.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
} }
destConnID := s.connIDManager.Get() destConnID := s.connIDManager.Get()
if hdr.SrcConnectionID.Equal(destConnID) { if hdr.SrcConnectionID.Equal(destConnID) {
if s.qlogger != nil { if s.tracer != nil {
s.qlogger.DroppedPacket(logging.PacketTypeRetry, protocol.ByteCount(len(data)), logging.PacketDropUnexpectedPacket) s.tracer.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
@ -881,8 +881,8 @@ 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.tracer != nil {
s.qlogger.DroppedPacket(logging.PacketTypeRetry, protocol.ByteCount(len(data)), logging.PacketDropPayloadDecryptError) s.tracer.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
@ -890,8 +890,8 @@ func (s *session) handleRetryPacket(hdr *wire.Header, data []byte) bool /* was t
s.logger.Debugf("<- Received Retry: %#v", hdr) s.logger.Debugf("<- Received Retry: %#v", hdr)
s.logger.Debugf("Switching destination connection ID to: %s", hdr.SrcConnectionID) s.logger.Debugf("Switching destination connection ID to: %s", hdr.SrcConnectionID)
if s.qlogger != nil { if s.tracer != nil {
s.qlogger.ReceivedRetry(hdr) s.tracer.ReceivedRetry(hdr)
} }
newDestConnID := hdr.SrcConnectionID newDestConnID := hdr.SrcConnectionID
s.receivedRetry = true s.receivedRetry = true
@ -911,16 +911,16 @@ func (s *session) handleRetryPacket(hdr *wire.Header, data []byte) bool /* was t
func (s *session) handleVersionNegotiationPacket(p *receivedPacket) { 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.tracer != nil {
s.qlogger.DroppedPacket(logging.PacketTypeVersionNegotiation, protocol.ByteCount(len(p.data)), logging.PacketDropUnexpectedPacket) s.tracer.DroppedPacket(logging.PacketTypeVersionNegotiation, protocol.ByteCount(len(p.data)), logging.PacketDropUnexpectedPacket)
} }
return return
} }
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.tracer != nil {
s.qlogger.DroppedPacket(logging.PacketTypeVersionNegotiation, protocol.ByteCount(len(p.data)), logging.PacketDropHeaderParseError) s.tracer.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
@ -928,8 +928,8 @@ 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.tracer != nil {
s.qlogger.DroppedPacket(logging.PacketTypeVersionNegotiation, protocol.ByteCount(len(p.data)), logging.PacketDropUnexpectedVersion) s.tracer.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.
@ -938,8 +938,8 @@ func (s *session) handleVersionNegotiationPacket(p *receivedPacket) {
} }
s.logger.Infof("Received a Version Negotiation packet. Supported Versions: %s", hdr.SupportedVersions) s.logger.Infof("Received a Version Negotiation packet. Supported Versions: %s", hdr.SupportedVersions)
if s.qlogger != nil { if s.tracer != nil {
s.qlogger.ReceivedVersionNegotiationPacket(hdr) s.tracer.ReceivedVersionNegotiationPacket(hdr)
} }
newVersion, ok := protocol.ChooseSupportedVersion(s.config.Versions, hdr.SupportedVersions) newVersion, ok := protocol.ChooseSupportedVersion(s.config.Versions, hdr.SupportedVersions)
if !ok { if !ok {
@ -985,8 +985,8 @@ func (s *session) handleUnpackedPacket(
s.handshakeDestConnID = packet.hdr.SrcConnectionID s.handshakeDestConnID = packet.hdr.SrcConnectionID
s.connIDManager.ChangeInitialConnID(packet.hdr.SrcConnectionID) s.connIDManager.ChangeInitialConnID(packet.hdr.SrcConnectionID)
} }
if s.qlogger != nil { if s.tracer != nil {
s.qlogger.StartedConnection( s.tracer.StartedConnection(
s.conn.LocalAddr(), s.conn.LocalAddr(),
s.conn.RemoteAddr(), s.conn.RemoteAddr(),
s.version, s.version,
@ -1019,12 +1019,12 @@ func (s *session) handleUnpackedPacket(
if ackhandler.IsFrameAckEliciting(frame) { if ackhandler.IsFrameAckEliciting(frame) {
isAckEliciting = true isAckEliciting = true
} }
if s.traceCallback != nil || s.qlogger != nil { if s.traceCallback != nil || s.tracer != nil {
frames = append(frames, frame) frames = append(frames, frame)
} }
// Only process frames now if we're not logging. // Only process frames now if we're not logging.
// If we're logging, we need to make sure that the packet_received event is logged first. // If we're logging, we need to make sure that the packet_received event is logged first.
if s.qlogger == nil { if s.tracer == nil {
if err := s.handleFrame(frame, packet.encryptionLevel); err != nil { if err := s.handleFrame(frame, packet.encryptionLevel); err != nil {
return err return err
} }
@ -1043,8 +1043,8 @@ func (s *session) handleUnpackedPacket(
Frames: frames, Frames: frames,
}) })
} }
if s.qlogger != nil { if s.tracer != nil {
s.qlogger.ReceivedPacket(packet.hdr, packetSize, frames) s.tracer.ReceivedPacket(packet.hdr, packetSize, frames)
for _, frame := range frames { for _, frame := range frames {
if err := s.handleFrame(frame, packet.encryptionLevel); err != nil { if err := s.handleFrame(frame, packet.encryptionLevel); err != nil {
return err return err
@ -1283,8 +1283,8 @@ func (s *session) handleCloseError(closeErr closeError) {
if closeErr.err == nil { if closeErr.err == nil {
closeErr.err = qerr.NewApplicationError(0, "") closeErr.err = qerr.NewApplicationError(0, "")
} }
if statelessReset, ok := closeErr.err.(interface{ StatelessResetToken() *[16]byte }); ok && s.qlogger != nil { if statelessReset, ok := closeErr.err.(interface{ StatelessResetToken() *[16]byte }); ok && s.tracer != nil {
s.qlogger.ReceivedStatelessReset(statelessReset.StatelessResetToken()) s.tracer.ReceivedStatelessReset(statelessReset.StatelessResetToken())
} }
var quicErr *qerr.QuicError var quicErr *qerr.QuicError
@ -1319,8 +1319,8 @@ func (s *session) dropEncryptionLevel(encLevel protocol.EncryptionLevel) {
} }
s.sentPacketHandler.DropPackets(encLevel) s.sentPacketHandler.DropPackets(encLevel)
s.receivedPacketHandler.DropPackets(encLevel) s.receivedPacketHandler.DropPackets(encLevel)
if s.qlogger != nil { if s.tracer != nil {
s.qlogger.DroppedEncryptionLevel(encLevel) s.tracer.DroppedEncryptionLevel(encLevel)
} }
} }
@ -1349,8 +1349,8 @@ func (s *session) processTransportParametersImpl(params *wire.TransportParameter
if s.logger.Debug() { if s.logger.Debug() {
s.logger.Debugf("Processed Transport Parameters: %s", params) s.logger.Debugf("Processed Transport Parameters: %s", params)
} }
if s.qlogger != nil { if s.tracer != nil {
s.qlogger.ReceivedTransportParameters(params) s.tracer.ReceivedTransportParameters(params)
} }
// check the initial_source_connection_id // check the initial_source_connection_id
@ -1556,13 +1556,13 @@ func (s *session) sendConnectionClose(quicErr *qerr.QuicError) ([]byte, error) {
} }
func (s *session) logPacketContents(now time.Time, p *packetContents) { func (s *session) logPacketContents(now time.Time, p *packetContents) {
// qlog // tracing
if s.qlogger != nil { if s.tracer != nil {
frames := make([]wire.Frame, 0, len(p.frames)) frames := make([]wire.Frame, 0, len(p.frames))
for _, f := range p.frames { for _, f := range p.frames {
frames = append(frames, f.Frame) frames = append(frames, f.Frame)
} }
s.qlogger.SentPacket(p.header, p.length, p.ack, frames) s.tracer.SentPacket(p.header, p.length, p.ack, frames)
} }
// quic-trace // quic-trace
@ -1676,15 +1676,15 @@ 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.tracer != nil {
s.qlogger.DroppedPacket(logging.PacketTypeFromHeader(hdr), protocol.ByteCount(len(p.data)), logging.PacketDropDOSPrevention) s.tracer.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.tracer != nil {
s.qlogger.BufferedPacket(logging.PacketTypeFromHeader(hdr)) s.tracer.BufferedPacket(logging.PacketTypeFromHeader(hdr))
} }
s.undecryptablePackets = append(s.undecryptablePackets, p) s.undecryptablePackets = append(s.undecryptablePackets, p)
} }

View file

@ -49,7 +49,7 @@ var _ = Describe("Session", func() {
streamManager *MockStreamManager streamManager *MockStreamManager
packer *MockPacker packer *MockPacker
cryptoSetup *mocks.MockCryptoSetup cryptoSetup *mocks.MockCryptoSetup
qlogger *mocks.MockTracer tracer *mocks.MockTracer
) )
remoteAddr := &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 1337} remoteAddr := &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 1337}
localAddr := &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 7331} localAddr := &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 7331}
@ -87,9 +87,9 @@ var _ = Describe("Session", func() {
mconn.EXPECT().LocalAddr().Return(localAddr).AnyTimes() mconn.EXPECT().LocalAddr().Return(localAddr).AnyTimes()
tokenGenerator, err := handshake.NewTokenGenerator() tokenGenerator, err := handshake.NewTokenGenerator()
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
qlogger = mocks.NewMockTracer(mockCtrl) tracer = mocks.NewMockTracer(mockCtrl)
qlogger.EXPECT().SentTransportParameters(gomock.Any()) tracer.EXPECT().SentTransportParameters(gomock.Any())
qlogger.EXPECT().UpdatedKeyFromTLS(gomock.Any(), gomock.Any()).AnyTimes() tracer.EXPECT().UpdatedKeyFromTLS(gomock.Any(), gomock.Any()).AnyTimes()
sess = newSession( sess = newSession(
mconn, mconn,
sessionRunner, sessionRunner,
@ -103,7 +103,7 @@ var _ = Describe("Session", func() {
nil, // tls.Config nil, // tls.Config
tokenGenerator, tokenGenerator,
false, false,
qlogger, tracer,
utils.DefaultLogger, utils.DefaultLogger,
protocol.VersionTLS, protocol.VersionTLS,
).(*session) ).(*session)
@ -337,7 +337,7 @@ var _ = Describe("Session", func() {
Expect(s).To(BeAssignableToTypeOf(&closedRemoteSession{})) Expect(s).To(BeAssignableToTypeOf(&closedRemoteSession{}))
}) })
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
qlogger.EXPECT().Export() tracer.EXPECT().Export()
go func() { go func() {
defer GinkgoRecover() defer GinkgoRecover()
@ -361,7 +361,7 @@ var _ = Describe("Session", func() {
Expect(s).To(BeAssignableToTypeOf(&closedRemoteSession{})) Expect(s).To(BeAssignableToTypeOf(&closedRemoteSession{}))
}) })
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
qlogger.EXPECT().Export() tracer.EXPECT().Export()
go func() { go func() {
defer GinkgoRecover() defer GinkgoRecover()
@ -429,7 +429,7 @@ var _ = Describe("Session", func() {
return &coalescedPacket{buffer: buffer}, nil return &coalescedPacket{buffer: buffer}, nil
}) })
mconn.EXPECT().Write([]byte("connection close")) mconn.EXPECT().Write([]byte("connection close"))
qlogger.EXPECT().Export() tracer.EXPECT().Export()
sess.shutdown() sess.shutdown()
Eventually(areSessionsRunning).Should(BeFalse()) Eventually(areSessionsRunning).Should(BeFalse())
Expect(sess.Context().Done()).To(BeClosed()) Expect(sess.Context().Done()).To(BeClosed())
@ -442,7 +442,7 @@ var _ = Describe("Session", func() {
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil) packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
mconn.EXPECT().Write(gomock.Any()) mconn.EXPECT().Write(gomock.Any())
qlogger.EXPECT().Export() tracer.EXPECT().Export()
sess.shutdown() sess.shutdown()
sess.shutdown() sess.shutdown()
Eventually(areSessionsRunning).Should(BeFalse()) Eventually(areSessionsRunning).Should(BeFalse())
@ -461,7 +461,7 @@ var _ = Describe("Session", func() {
return &coalescedPacket{buffer: getPacketBuffer()}, nil return &coalescedPacket{buffer: getPacketBuffer()}, nil
}) })
mconn.EXPECT().Write(gomock.Any()) mconn.EXPECT().Write(gomock.Any())
qlogger.EXPECT().Export() tracer.EXPECT().Export()
sess.CloseWithError(0x1337, "test error") sess.CloseWithError(0x1337, "test error")
Eventually(areSessionsRunning).Should(BeFalse()) Eventually(areSessionsRunning).Should(BeFalse())
Expect(sess.Context().Done()).To(BeClosed()) Expect(sess.Context().Done()).To(BeClosed())
@ -481,7 +481,7 @@ var _ = Describe("Session", func() {
return &coalescedPacket{buffer: getPacketBuffer()}, nil return &coalescedPacket{buffer: getPacketBuffer()}, nil
}) })
mconn.EXPECT().Write(gomock.Any()) mconn.EXPECT().Write(gomock.Any())
qlogger.EXPECT().Export() tracer.EXPECT().Export()
sess.closeLocal(testErr) sess.closeLocal(testErr)
Eventually(areSessionsRunning).Should(BeFalse()) Eventually(areSessionsRunning).Should(BeFalse())
Expect(sess.Context().Done()).To(BeClosed()) Expect(sess.Context().Done()).To(BeClosed())
@ -494,7 +494,7 @@ var _ = Describe("Session", func() {
sessionRunner.EXPECT().Remove(gomock.Any()).AnyTimes() sessionRunner.EXPECT().Remove(gomock.Any()).AnyTimes()
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
// don't EXPECT any calls to mconn.Write() // don't EXPECT any calls to mconn.Write()
qlogger.EXPECT().Export() tracer.EXPECT().Export()
sess.destroy(testErr) sess.destroy(testErr)
Eventually(areSessionsRunning).Should(BeFalse()) Eventually(areSessionsRunning).Should(BeFalse())
expectedRunErr = testErr expectedRunErr = testErr
@ -516,7 +516,7 @@ var _ = Describe("Session", func() {
}() }()
Consistently(returned).ShouldNot(BeClosed()) Consistently(returned).ShouldNot(BeClosed())
mconn.EXPECT().Write(gomock.Any()) mconn.EXPECT().Write(gomock.Any())
qlogger.EXPECT().Export() tracer.EXPECT().Export()
sess.shutdown() sess.shutdown()
Eventually(returned).Should(BeClosed()) Eventually(returned).Should(BeClosed())
}) })
@ -545,9 +545,9 @@ var _ = Describe("Session", func() {
}, nil }, nil
}) })
gomock.InOrder( gomock.InOrder(
qlogger.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()), tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()),
qlogger.EXPECT().ReceivedPacket(gomock.Any(), gomock.Any(), gomock.Any()), tracer.EXPECT().ReceivedPacket(gomock.Any(), gomock.Any(), gomock.Any()),
qlogger.EXPECT().Export(), tracer.EXPECT().Export(),
) )
// don't EXPECT any calls to packer.PackPacket() // don't EXPECT any calls to packer.PackPacket()
sess.handlePacket(&receivedPacket{ sess.handlePacket(&receivedPacket{
@ -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(logging.PacketTypeRetry, protocol.ByteCount(len(p.data)), logging.PacketDropUnexpectedPacket) tracer.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(logging.PacketTypeVersionNegotiation, protocol.ByteCount(len(b)), logging.PacketDropUnexpectedPacket) tracer.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(logging.PacketTypeNotDetermined, protocol.ByteCount(len(p.data)), logging.PacketDropHeaderParseError) tracer.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(logging.PacketTypeNotDetermined, protocol.ByteCount(len(p.data)), logging.PacketDropUnsupportedVersion) tracer.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(logging.PacketTypeHandshake, protocol.ByteCount(len(p.data)), logging.PacketDropUnexpectedVersion) tracer.EXPECT().DroppedPacket(logging.PacketTypeHandshake, protocol.ByteCount(len(p.data)), logging.PacketDropUnexpectedVersion)
Expect(sess.handlePacketImpl(p)).To(BeFalse()) Expect(sess.handlePacketImpl(p)).To(BeFalse())
}) })
@ -671,8 +671,8 @@ var _ = Describe("Session", func() {
) )
sess.receivedPacketHandler = rph sess.receivedPacketHandler = rph
packet.rcvTime = rcvTime packet.rcvTime = rcvTime
qlogger.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()) tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
qlogger.EXPECT().ReceivedPacket(hdr, protocol.ByteCount(len(packet.data)), nil) tracer.EXPECT().ReceivedPacket(hdr, protocol.ByteCount(len(packet.data)), nil)
Expect(sess.handlePacketImpl(packet)).To(BeTrue()) Expect(sess.handlePacketImpl(packet)).To(BeTrue())
}) })
@ -699,8 +699,8 @@ var _ = Describe("Session", func() {
) )
sess.receivedPacketHandler = rph sess.receivedPacketHandler = rph
packet.rcvTime = rcvTime packet.rcvTime = rcvTime
qlogger.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()) tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
qlogger.EXPECT().ReceivedPacket(hdr, protocol.ByteCount(len(packet.data)), []wire.Frame{&wire.PingFrame{}}) tracer.EXPECT().ReceivedPacket(hdr, protocol.ByteCount(len(packet.data)), []wire.Frame{&wire.PingFrame{}})
Expect(sess.handlePacketImpl(packet)).To(BeTrue()) Expect(sess.handlePacketImpl(packet)).To(BeTrue())
}) })
@ -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(logging.PacketType1RTT, protocol.ByteCount(len(packet.data)), logging.PacketDropDuplicate) tracer.EXPECT().DroppedPacket(logging.PacketType1RTT, protocol.ByteCount(len(packet.data)), logging.PacketDropDuplicate)
Expect(sess.handlePacketImpl(packet)).To(BeFalse()) Expect(sess.handlePacketImpl(packet)).To(BeFalse())
}) })
@ -746,11 +746,11 @@ var _ = Describe("Session", func() {
PacketNumber: 0x1337, PacketNumber: 0x1337,
PacketNumberLen: protocol.PacketNumberLen2, PacketNumberLen: protocol.PacketNumberLen2,
}, []byte("foobar")) }, []byte("foobar"))
qlogger.EXPECT().DroppedPacket(logging.PacketTypeHandshake, protocol.ByteCount(len(p.data)), logging.PacketDropPayloadDecryptError) tracer.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
qlogger.EXPECT().Export() tracer.EXPECT().Export()
mconn.EXPECT().Write(gomock.Any()) mconn.EXPECT().Write(gomock.Any())
sess.closeLocal(errors.New("close")) sess.closeLocal(errors.New("close"))
Eventually(sess.Context().Done()).Should(BeClosed()) Eventually(sess.Context().Done()).Should(BeClosed())
@ -776,7 +776,7 @@ var _ = Describe("Session", func() {
Header: wire.Header{DestConnectionID: srcConnID}, Header: wire.Header{DestConnectionID: srcConnID},
PacketNumberLen: protocol.PacketNumberLen1, PacketNumberLen: protocol.PacketNumberLen1,
}, nil) }, nil)
qlogger.EXPECT().Export() tracer.EXPECT().Export()
sess.handlePacket(packet) sess.handlePacket(packet)
Eventually(sess.Context().Done()).Should(BeClosed()) Eventually(sess.Context().Done()).Should(BeClosed())
}) })
@ -794,14 +794,14 @@ var _ = Describe("Session", func() {
runErr <- sess.run() runErr <- sess.run()
}() }()
expectReplaceWithClosed() expectReplaceWithClosed()
qlogger.EXPECT().DroppedPacket(logging.PacketType1RTT, gomock.Any(), logging.PacketDropPayloadDecryptError) tracer.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,
}, nil)) }, nil))
Consistently(runErr).ShouldNot(Receive()) Consistently(runErr).ShouldNot(Receive())
// make the go routine return // make the go routine return
qlogger.EXPECT().Export() tracer.EXPECT().Export()
mconn.EXPECT().Write(gomock.Any()) mconn.EXPECT().Write(gomock.Any())
sess.shutdown() sess.shutdown()
Eventually(sess.Context().Done()).Should(BeClosed()) Eventually(sess.Context().Done()).Should(BeClosed())
@ -825,7 +825,7 @@ var _ = Describe("Session", func() {
}() }()
expectReplaceWithClosed() expectReplaceWithClosed()
mconn.EXPECT().Write(gomock.Any()) mconn.EXPECT().Write(gomock.Any())
qlogger.EXPECT().Export() tracer.EXPECT().Export()
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,
@ -867,12 +867,12 @@ var _ = Describe("Session", func() {
data: []byte{0}, // one PADDING frame data: []byte{0}, // one PADDING frame
}, nil) }, nil)
p1 := getPacket(hdr1, nil) p1 := getPacket(hdr1, nil)
qlogger.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()) tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
qlogger.EXPECT().ReceivedPacket(gomock.Any(), protocol.ByteCount(len(p1.data)), gomock.Any()) tracer.EXPECT().ReceivedPacket(gomock.Any(), protocol.ByteCount(len(p1.data)), gomock.Any())
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(logging.PacketTypeHandshake, protocol.ByteCount(len(p2.data)), logging.PacketDropUnknownConnectionID) tracer.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(logging.PacketTypeHandshake) tracer.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}))
}) })
@ -909,15 +909,15 @@ var _ = Describe("Session", func() {
PacketNumberLen: protocol.PacketNumberLen1, PacketNumberLen: protocol.PacketNumberLen1,
}, nil) }, nil)
packet.remoteAddr = &net.IPAddr{IP: net.IPv4(192, 168, 0, 100)} packet.remoteAddr = &net.IPAddr{IP: net.IPv4(192, 168, 0, 100)}
qlogger.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()) tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
qlogger.EXPECT().ReceivedPacket(gomock.Any(), protocol.ByteCount(len(packet.data)), gomock.Any()) tracer.EXPECT().ReceivedPacket(gomock.Any(), protocol.ByteCount(len(packet.data)), gomock.Any())
Expect(sess.handlePacketImpl(packet)).To(BeTrue()) Expect(sess.handlePacketImpl(packet)).To(BeTrue())
}) })
}) })
Context("coalesced packets", func() { Context("coalesced packets", func() {
BeforeEach(func() { BeforeEach(func() {
qlogger.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).MaxTimes(1) tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).MaxTimes(1)
}) })
getPacketWithLength := func(connID protocol.ConnectionID, length protocol.ByteCount) (int /* header length */, *receivedPacket) { getPacketWithLength := func(connID protocol.ConnectionID, length protocol.ByteCount) (int /* header length */, *receivedPacket) {
hdr := &wire.ExtendedHeader{ hdr := &wire.ExtendedHeader{
@ -948,7 +948,7 @@ var _ = Describe("Session", func() {
hdr: &wire.ExtendedHeader{}, hdr: &wire.ExtendedHeader{},
}, nil }, nil
}) })
qlogger.EXPECT().ReceivedPacket(gomock.Any(), protocol.ByteCount(len(packet.data)), gomock.Any()) tracer.EXPECT().ReceivedPacket(gomock.Any(), protocol.ByteCount(len(packet.data)), gomock.Any())
Expect(sess.handlePacketImpl(packet)).To(BeTrue()) Expect(sess.handlePacketImpl(packet)).To(BeTrue())
}) })
@ -974,8 +974,8 @@ var _ = Describe("Session", func() {
}, nil }, nil
}) })
gomock.InOrder( gomock.InOrder(
qlogger.EXPECT().ReceivedPacket(gomock.Any(), protocol.ByteCount(len(packet1.data)), gomock.Any()), tracer.EXPECT().ReceivedPacket(gomock.Any(), protocol.ByteCount(len(packet1.data)), gomock.Any()),
qlogger.EXPECT().ReceivedPacket(gomock.Any(), protocol.ByteCount(len(packet2.data)), gomock.Any()), tracer.EXPECT().ReceivedPacket(gomock.Any(), protocol.ByteCount(len(packet2.data)), gomock.Any()),
) )
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())
@ -997,8 +997,8 @@ var _ = Describe("Session", func() {
}), }),
) )
gomock.InOrder( gomock.InOrder(
qlogger.EXPECT().BufferedPacket(gomock.Any()), tracer.EXPECT().BufferedPacket(gomock.Any()),
qlogger.EXPECT().ReceivedPacket(gomock.Any(), protocol.ByteCount(len(packet2.data)), gomock.Any()), tracer.EXPECT().ReceivedPacket(gomock.Any(), protocol.ByteCount(len(packet2.data)), gomock.Any()),
) )
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())
@ -1022,8 +1022,8 @@ var _ = Describe("Session", func() {
_, packet2 := getPacketWithLength(wrongConnID, 123) _, packet2 := getPacketWithLength(wrongConnID, 123)
// 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()), tracer.EXPECT().ReceivedPacket(gomock.Any(), protocol.ByteCount(len(packet1.data)), gomock.Any()),
qlogger.EXPECT().DroppedPacket(gomock.Any(), protocol.ByteCount(len(packet2.data)), logging.PacketDropUnknownConnectionID), tracer.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())
@ -1044,7 +1044,7 @@ var _ = Describe("Session", func() {
expectReplaceWithClosed() expectReplaceWithClosed()
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
mconn.EXPECT().Write(gomock.Any()) mconn.EXPECT().Write(gomock.Any())
qlogger.EXPECT().Export() tracer.EXPECT().Export()
sess.shutdown() sess.shutdown()
Eventually(sess.Context().Done()).Should(BeClosed()) Eventually(sess.Context().Done()).Should(BeClosed())
Eventually(sessionDone).Should(BeClosed()) Eventually(sessionDone).Should(BeClosed())
@ -1074,7 +1074,7 @@ var _ = Describe("Session", func() {
packer.EXPECT().PackPacket().Return(nil, nil).AnyTimes() packer.EXPECT().PackPacket().Return(nil, nil).AnyTimes()
sent := make(chan struct{}) sent := make(chan struct{})
mconn.EXPECT().Write(gomock.Any()).Do(func([]byte) { close(sent) }) mconn.EXPECT().Write(gomock.Any()).Do(func([]byte) { close(sent) })
qlogger.EXPECT().SentPacket(p.header, p.buffer.Len(), nil, []wire.Frame{}) tracer.EXPECT().SentPacket(p.header, p.buffer.Len(), nil, []wire.Frame{})
sess.scheduleSending() sess.scheduleSending()
Eventually(sent).Should(BeClosed()) Eventually(sent).Should(BeClosed())
}) })
@ -1120,7 +1120,7 @@ var _ = Describe("Session", func() {
runSession() runSession()
sent := make(chan struct{}) sent := make(chan struct{})
mconn.EXPECT().Write(gomock.Any()).Do(func([]byte) { close(sent) }) mconn.EXPECT().Write(gomock.Any()).Do(func([]byte) { close(sent) })
qlogger.EXPECT().SentPacket(p.header, p.length, nil, []wire.Frame{}) tracer.EXPECT().SentPacket(p.header, p.length, nil, []wire.Frame{})
sess.scheduleSending() sess.scheduleSending()
Eventually(sent).Should(BeClosed()) Eventually(sent).Should(BeClosed())
frames, _ := sess.framer.AppendControlFrames(nil, 1000) frames, _ := sess.framer.AppendControlFrames(nil, 1000)
@ -1175,7 +1175,7 @@ var _ = Describe("Session", func() {
runSession() runSession()
sent := make(chan struct{}) sent := make(chan struct{})
mconn.EXPECT().Write(gomock.Any()).Do(func([]byte) { close(sent) }) mconn.EXPECT().Write(gomock.Any()).Do(func([]byte) { close(sent) })
qlogger.EXPECT().SentPacket(p.header, p.length, gomock.Any(), gomock.Any()) tracer.EXPECT().SentPacket(p.header, p.length, gomock.Any(), gomock.Any())
sess.scheduleSending() sess.scheduleSending()
Eventually(sent).Should(BeClosed()) Eventually(sent).Should(BeClosed())
}) })
@ -1196,7 +1196,7 @@ var _ = Describe("Session", func() {
runSession() runSession()
sent := make(chan struct{}) sent := make(chan struct{})
mconn.EXPECT().Write(gomock.Any()).Do(func([]byte) { close(sent) }) mconn.EXPECT().Write(gomock.Any()).Do(func([]byte) { close(sent) })
qlogger.EXPECT().SentPacket(p.header, p.length, gomock.Any(), gomock.Any()) tracer.EXPECT().SentPacket(p.header, p.length, gomock.Any(), gomock.Any())
sess.scheduleSending() sess.scheduleSending()
Eventually(sent).Should(BeClosed()) Eventually(sent).Should(BeClosed())
// We're using a mock packet packer in this test. // We're using a mock packet packer in this test.
@ -1211,7 +1211,7 @@ var _ = Describe("Session", func() {
var sph *mockackhandler.MockSentPacketHandler var sph *mockackhandler.MockSentPacketHandler
BeforeEach(func() { BeforeEach(func() {
qlogger.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes() tracer.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes()
sph = mockackhandler.NewMockSentPacketHandler(mockCtrl) sph = mockackhandler.NewMockSentPacketHandler(mockCtrl)
sph.EXPECT().GetLossDetectionTimeout().AnyTimes() sph.EXPECT().GetLossDetectionTimeout().AnyTimes()
sess.handshakeConfirmed = true sess.handshakeConfirmed = true
@ -1226,7 +1226,7 @@ var _ = Describe("Session", func() {
expectReplaceWithClosed() expectReplaceWithClosed()
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
mconn.EXPECT().Write(gomock.Any()) mconn.EXPECT().Write(gomock.Any())
qlogger.EXPECT().Export() tracer.EXPECT().Export()
sess.shutdown() sess.shutdown()
Eventually(sess.Context().Done()).Should(BeClosed()) Eventually(sess.Context().Done()).Should(BeClosed())
}) })
@ -1348,7 +1348,7 @@ var _ = Describe("Session", func() {
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil) packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
mconn.EXPECT().Write(gomock.Any()) mconn.EXPECT().Write(gomock.Any())
qlogger.EXPECT().Export() tracer.EXPECT().Export()
sess.shutdown() sess.shutdown()
Eventually(sess.Context().Done()).Should(BeClosed()) Eventually(sess.Context().Done()).Should(BeClosed())
}) })
@ -1374,7 +1374,7 @@ var _ = Describe("Session", func() {
// only EXPECT calls after scheduleSending is called // only EXPECT calls after scheduleSending is called
written := make(chan struct{}) written := make(chan struct{})
mconn.EXPECT().Write(gomock.Any()).Do(func([]byte) { close(written) }) mconn.EXPECT().Write(gomock.Any()).Do(func([]byte) { close(written) })
qlogger.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes() tracer.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes()
sess.scheduleSending() sess.scheduleSending()
Eventually(written).Should(BeClosed()) Eventually(written).Should(BeClosed())
}) })
@ -1398,7 +1398,7 @@ var _ = Describe("Session", func() {
written := make(chan struct{}) written := make(chan struct{})
mconn.EXPECT().Write(gomock.Any()).Do(func([]byte) { close(written) }) mconn.EXPECT().Write(gomock.Any()).Do(func([]byte) { close(written) })
qlogger.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes() tracer.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes()
go func() { go func() {
defer GinkgoRecover() defer GinkgoRecover()
cryptoSetup.EXPECT().RunHandshake().MaxTimes(1) cryptoSetup.EXPECT().RunHandshake().MaxTimes(1)
@ -1460,10 +1460,10 @@ var _ = Describe("Session", func() {
}), }),
) )
gomock.InOrder( gomock.InOrder(
qlogger.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Do(func(hdr *wire.ExtendedHeader, _ protocol.ByteCount, _ *wire.AckFrame, _ []wire.Frame) { tracer.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Do(func(hdr *wire.ExtendedHeader, _ protocol.ByteCount, _ *wire.AckFrame, _ []wire.Frame) {
Expect(hdr.Type).To(Equal(protocol.PacketTypeInitial)) Expect(hdr.Type).To(Equal(protocol.PacketTypeInitial))
}), }),
qlogger.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Do(func(hdr *wire.ExtendedHeader, _ protocol.ByteCount, _ *wire.AckFrame, _ []wire.Frame) { tracer.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Do(func(hdr *wire.ExtendedHeader, _ protocol.ByteCount, _ *wire.AckFrame, _ []wire.Frame) {
Expect(hdr.Type).To(Equal(protocol.PacketTypeHandshake)) Expect(hdr.Type).To(Equal(protocol.PacketTypeHandshake))
}), }),
) )
@ -1486,7 +1486,7 @@ var _ = Describe("Session", func() {
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil) packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
mconn.EXPECT().Write(gomock.Any()) mconn.EXPECT().Write(gomock.Any())
qlogger.EXPECT().Export() tracer.EXPECT().Export()
sess.shutdown() sess.shutdown()
Eventually(sess.Context().Done()).Should(BeClosed()) Eventually(sess.Context().Done()).Should(BeClosed())
}) })
@ -1522,7 +1522,7 @@ var _ = Describe("Session", func() {
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil) packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
mconn.EXPECT().Write(gomock.Any()) mconn.EXPECT().Write(gomock.Any())
qlogger.EXPECT().Export() tracer.EXPECT().Export()
sess.shutdown() sess.shutdown()
Eventually(sess.Context().Done()).Should(BeClosed()) Eventually(sess.Context().Done()).Should(BeClosed())
}) })
@ -1566,7 +1566,7 @@ var _ = Describe("Session", func() {
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil) packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
mconn.EXPECT().Write(gomock.Any()) mconn.EXPECT().Write(gomock.Any())
qlogger.EXPECT().Export() tracer.EXPECT().Export()
sess.shutdown() sess.shutdown()
Eventually(sess.Context().Done()).Should(BeClosed()) Eventually(sess.Context().Done()).Should(BeClosed())
}) })
@ -1577,7 +1577,7 @@ var _ = Describe("Session", func() {
expectReplaceWithClosed() expectReplaceWithClosed()
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil) packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
qlogger.EXPECT().Export() tracer.EXPECT().Export()
go func() { go func() {
defer GinkgoRecover() defer GinkgoRecover()
cryptoSetup.EXPECT().RunHandshake() cryptoSetup.EXPECT().RunHandshake()
@ -1630,7 +1630,7 @@ var _ = Describe("Session", func() {
expectReplaceWithClosed() expectReplaceWithClosed()
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil) packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
qlogger.EXPECT().Export() tracer.EXPECT().Export()
sess.shutdown() sess.shutdown()
Eventually(sess.Context().Done()).Should(BeClosed()) Eventually(sess.Context().Done()).Should(BeClosed())
}) })
@ -1648,7 +1648,7 @@ var _ = Describe("Session", func() {
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil) packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
mconn.EXPECT().Write(gomock.Any()) mconn.EXPECT().Write(gomock.Any())
qlogger.EXPECT().Export() tracer.EXPECT().Export()
sess.shutdown() sess.shutdown()
Eventually(done).Should(BeClosed()) Eventually(done).Should(BeClosed())
}) })
@ -1668,7 +1668,7 @@ var _ = Describe("Session", func() {
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil) packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
mconn.EXPECT().Write(gomock.Any()) mconn.EXPECT().Write(gomock.Any())
qlogger.EXPECT().Export() tracer.EXPECT().Export()
Expect(sess.CloseWithError(0x1337, testErr.Error())).To(Succeed()) Expect(sess.CloseWithError(0x1337, testErr.Error())).To(Succeed())
Eventually(done).Should(BeClosed()) Eventually(done).Should(BeClosed())
}) })
@ -1690,7 +1690,7 @@ var _ = Describe("Session", func() {
Expect(sess.earlySessionReady()).ToNot(BeClosed()) Expect(sess.earlySessionReady()).ToNot(BeClosed())
sessionRunner.EXPECT().GetStatelessResetToken(gomock.Any()).Times(2) sessionRunner.EXPECT().GetStatelessResetToken(gomock.Any()).Times(2)
sessionRunner.EXPECT().Add(gomock.Any(), sess).Times(2) sessionRunner.EXPECT().Add(gomock.Any(), sess).Times(2)
qlogger.EXPECT().ReceivedTransportParameters(params) tracer.EXPECT().ReceivedTransportParameters(params)
sess.processTransportParameters(params) sess.processTransportParameters(params)
Expect(sess.earlySessionReady()).To(BeClosed()) Expect(sess.earlySessionReady()).To(BeClosed())
}) })
@ -1700,7 +1700,7 @@ var _ = Describe("Session", func() {
setRemoteIdleTimeout := func(t time.Duration) { setRemoteIdleTimeout := func(t time.Duration) {
streamManager.EXPECT().UpdateLimits(gomock.Any()) streamManager.EXPECT().UpdateLimits(gomock.Any())
packer.EXPECT().HandleTransportParameters(gomock.Any()) packer.EXPECT().HandleTransportParameters(gomock.Any())
qlogger.EXPECT().ReceivedTransportParameters(gomock.Any()) tracer.EXPECT().ReceivedTransportParameters(gomock.Any())
sess.processTransportParameters(&wire.TransportParameters{ sess.processTransportParameters(&wire.TransportParameters{
MaxIdleTimeout: t, MaxIdleTimeout: t,
InitialSourceConnectionID: destConnID, InitialSourceConnectionID: destConnID,
@ -1728,7 +1728,7 @@ var _ = Describe("Session", func() {
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil) packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
mconn.EXPECT().Write(gomock.Any()) mconn.EXPECT().Write(gomock.Any())
qlogger.EXPECT().Export() tracer.EXPECT().Export()
sess.shutdown() sess.shutdown()
Eventually(sess.Context().Done()).Should(BeClosed()) Eventually(sess.Context().Done()).Should(BeClosed())
}) })
@ -1789,8 +1789,8 @@ 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(logging.CloseReasonIdleTimeout), tracer.EXPECT().ClosedConnection(logging.CloseReasonIdleTimeout),
qlogger.EXPECT().Export(), tracer.EXPECT().Export(),
) )
go func() { go func() {
defer GinkgoRecover() defer GinkgoRecover()
@ -1811,8 +1811,8 @@ 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(logging.CloseReasonHandshakeTimeout), tracer.EXPECT().ClosedConnection(logging.CloseReasonHandshakeTimeout),
qlogger.EXPECT().Export(), tracer.EXPECT().Export(),
) )
done := make(chan struct{}) done := make(chan struct{})
go func() { go func() {
@ -1836,7 +1836,7 @@ var _ = Describe("Session", func() {
Expect(quicErr.ErrorCode).To(Equal(qerr.NoError)) Expect(quicErr.ErrorCode).To(Equal(qerr.NoError))
return &coalescedPacket{buffer: getPacketBuffer()}, nil return &coalescedPacket{buffer: getPacketBuffer()}, nil
}) })
qlogger.EXPECT().Export() tracer.EXPECT().Export()
// the handshake timeout is irrelevant here, since it depends on the time the session was created, // the handshake timeout is irrelevant here, since it depends on the time the session was created,
// and not on the last network activity // and not on the last network activity
go func() { go func() {
@ -1861,8 +1861,8 @@ var _ = Describe("Session", func() {
) )
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
gomock.InOrder( gomock.InOrder(
qlogger.EXPECT().ClosedConnection(logging.CloseReasonIdleTimeout), tracer.EXPECT().ClosedConnection(logging.CloseReasonIdleTimeout),
qlogger.EXPECT().Export(), tracer.EXPECT().Export(),
) )
sess.idleTimeout = 0 sess.idleTimeout = 0
done := make(chan struct{}) done := make(chan struct{})
@ -1897,7 +1897,7 @@ var _ = Describe("Session", func() {
expectReplaceWithClosed() expectReplaceWithClosed()
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
mconn.EXPECT().Write(gomock.Any()) mconn.EXPECT().Write(gomock.Any())
qlogger.EXPECT().Export() tracer.EXPECT().Export()
sess.shutdown() sess.shutdown()
Eventually(sess.Context().Done()).Should(BeClosed()) Eventually(sess.Context().Done()).Should(BeClosed())
}) })
@ -1981,7 +1981,7 @@ var _ = Describe("Client Session", func() {
packer *MockPacker packer *MockPacker
mconn *MockConnection mconn *MockConnection
cryptoSetup *mocks.MockCryptoSetup cryptoSetup *mocks.MockCryptoSetup
qlogger *mocks.MockTracer tracer *mocks.MockTracer
tlsConf *tls.Config tlsConf *tls.Config
quicConf *Config quicConf *Config
) )
@ -2020,9 +2020,9 @@ var _ = Describe("Client Session", func() {
tlsConf = &tls.Config{} tlsConf = &tls.Config{}
} }
sessionRunner = NewMockSessionRunner(mockCtrl) sessionRunner = NewMockSessionRunner(mockCtrl)
qlogger = mocks.NewMockTracer(mockCtrl) tracer = mocks.NewMockTracer(mockCtrl)
qlogger.EXPECT().SentTransportParameters(gomock.Any()) tracer.EXPECT().SentTransportParameters(gomock.Any())
qlogger.EXPECT().UpdatedKeyFromTLS(gomock.Any(), gomock.Any()).AnyTimes() tracer.EXPECT().UpdatedKeyFromTLS(gomock.Any(), gomock.Any()).AnyTimes()
sess = newClientSession( sess = newClientSession(
mconn, mconn,
sessionRunner, sessionRunner,
@ -2034,7 +2034,7 @@ var _ = Describe("Client Session", func() {
protocol.VersionTLS, protocol.VersionTLS,
false, false,
false, false,
qlogger, tracer,
utils.DefaultLogger, utils.DefaultLogger,
protocol.VersionTLS, protocol.VersionTLS,
).(*session) ).(*session)
@ -2071,14 +2071,14 @@ var _ = Describe("Client Session", func() {
}, },
PacketNumberLen: protocol.PacketNumberLen2, PacketNumberLen: protocol.PacketNumberLen2,
}, []byte("foobar")) }, []byte("foobar"))
qlogger.EXPECT().ReceivedPacket(gomock.Any(), protocol.ByteCount(len(p.data)), nil) tracer.EXPECT().ReceivedPacket(gomock.Any(), protocol.ByteCount(len(p.data)), nil)
Expect(sess.handlePacketImpl(p)).To(BeTrue()) Expect(sess.handlePacketImpl(p)).To(BeTrue())
// make sure the go routine returns // make sure the go routine returns
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil) packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
expectReplaceWithClosed() expectReplaceWithClosed()
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
mconn.EXPECT().Write(gomock.Any()) mconn.EXPECT().Write(gomock.Any())
qlogger.EXPECT().Export() tracer.EXPECT().Export()
sess.shutdown() sess.shutdown()
Eventually(sess.Context().Done()).Should(BeClosed()) Eventually(sess.Context().Done()).Should(BeClosed())
}) })
@ -2106,7 +2106,7 @@ var _ = Describe("Client Session", func() {
DestConnectionID: srcConnID, DestConnectionID: srcConnID,
SrcConnectionID: destConnID, SrcConnectionID: destConnID,
} }
qlogger.EXPECT().ReceivedPacket(gomock.Any(), gomock.Any(), gomock.Any()) tracer.EXPECT().ReceivedPacket(gomock.Any(), gomock.Any(), gomock.Any())
Expect(sess.handleSinglePacket(&receivedPacket{buffer: getPacketBuffer()}, hdr)).To(BeTrue()) Expect(sess.handleSinglePacket(&receivedPacket{buffer: getPacketBuffer()}, hdr)).To(BeTrue())
}) })
@ -2154,7 +2154,7 @@ var _ = Describe("Client Session", func() {
errChan <- sess.run() errChan <- sess.run()
}() }()
sessionRunner.EXPECT().Remove(srcConnID) sessionRunner.EXPECT().Remove(srcConnID)
qlogger.EXPECT().ReceivedVersionNegotiationPacket(gomock.Any()).Do(func(hdr *wire.Header) { tracer.EXPECT().ReceivedVersionNegotiationPacket(gomock.Any()).Do(func(hdr *wire.Header) {
Expect(hdr.Version).To(BeZero()) Expect(hdr.Version).To(BeZero())
Expect(hdr.SupportedVersions).To(And( Expect(hdr.SupportedVersions).To(And(
ContainElement(protocol.VersionNumber(4321)), ContainElement(protocol.VersionNumber(4321)),
@ -2181,8 +2181,8 @@ var _ = Describe("Client Session", func() {
}() }()
sessionRunner.EXPECT().Remove(srcConnID).MaxTimes(1) sessionRunner.EXPECT().Remove(srcConnID).MaxTimes(1)
gomock.InOrder( gomock.InOrder(
qlogger.EXPECT().ReceivedVersionNegotiationPacket(gomock.Any()), tracer.EXPECT().ReceivedVersionNegotiationPacket(gomock.Any()),
qlogger.EXPECT().Export(), tracer.EXPECT().Export(),
) )
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
Expect(sess.handlePacketImpl(getVNP(12345678))).To(BeFalse()) Expect(sess.handlePacketImpl(getVNP(12345678))).To(BeFalse())
@ -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(logging.PacketTypeVersionNegotiation, protocol.ByteCount(len(p.data)), logging.PacketDropUnexpectedVersion) tracer.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(logging.PacketTypeVersionNegotiation, protocol.ByteCount(len(p.data)), logging.PacketDropHeaderParseError) tracer.EXPECT().DroppedPacket(logging.PacketTypeVersionNegotiation, protocol.ByteCount(len(p.data)), logging.PacketDropHeaderParseError)
Expect(sess.handlePacketImpl(p)).To(BeFalse()) Expect(sess.handlePacketImpl(p)).To(BeFalse())
}) })
}) })
@ -2238,7 +2238,7 @@ var _ = Describe("Client Session", func() {
sph.EXPECT().ResetForRetry() sph.EXPECT().ResetForRetry()
cryptoSetup.EXPECT().ChangeConnectionID(protocol.ConnectionID{0xde, 0xad, 0xbe, 0xef}) cryptoSetup.EXPECT().ChangeConnectionID(protocol.ConnectionID{0xde, 0xad, 0xbe, 0xef})
packer.EXPECT().SetToken([]byte("foobar")) packer.EXPECT().SetToken([]byte("foobar"))
qlogger.EXPECT().ReceivedRetry(gomock.Any()).Do(func(hdr *wire.Header) { tracer.EXPECT().ReceivedRetry(gomock.Any()).Do(func(hdr *wire.Header) {
Expect(hdr.DestConnectionID).To(Equal(retryHdr.DestConnectionID)) Expect(hdr.DestConnectionID).To(Equal(retryHdr.DestConnectionID))
Expect(hdr.SrcConnectionID).To(Equal(retryHdr.SrcConnectionID)) Expect(hdr.SrcConnectionID).To(Equal(retryHdr.SrcConnectionID))
Expect(hdr.Token).To(Equal(retryHdr.Token)) Expect(hdr.Token).To(Equal(retryHdr.Token))
@ -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(logging.PacketTypeRetry, protocol.ByteCount(len(p.data)), logging.PacketDropUnexpectedPacket) tracer.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(logging.PacketTypeRetry, protocol.ByteCount(len(p.data)), logging.PacketDropUnexpectedPacket) tracer.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(logging.PacketTypeRetry, protocol.ByteCount(len(p.data)), logging.PacketDropPayloadDecryptError) tracer.EXPECT().DroppedPacket(logging.PacketTypeRetry, protocol.ByteCount(len(p.data)), logging.PacketDropPayloadDecryptError)
Expect(sess.handlePacketImpl(p)).To(BeFalse()) Expect(sess.handlePacketImpl(p)).To(BeFalse())
}) })
}) })
@ -2295,7 +2295,7 @@ var _ = Describe("Client Session", func() {
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil).MaxTimes(1) packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil).MaxTimes(1)
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
mconn.EXPECT().Write(gomock.Any()) mconn.EXPECT().Write(gomock.Any())
qlogger.EXPECT().Export() tracer.EXPECT().Export()
} }
closed = true closed = true
} }
@ -2320,7 +2320,7 @@ var _ = Describe("Client Session", func() {
} }
packer.EXPECT().HandleTransportParameters(gomock.Any()) packer.EXPECT().HandleTransportParameters(gomock.Any())
packer.EXPECT().PackCoalescedPacket(protocol.MaxByteCount).MaxTimes(1) packer.EXPECT().PackCoalescedPacket(protocol.MaxByteCount).MaxTimes(1)
qlogger.EXPECT().ReceivedTransportParameters(params) tracer.EXPECT().ReceivedTransportParameters(params)
sess.processTransportParameters(params) sess.processTransportParameters(params)
// make sure the connection ID is not retired // make sure the connection ID is not retired
cf, _ := sess.framer.AppendControlFrames(nil, protocol.MaxByteCount) cf, _ := sess.framer.AppendControlFrames(nil, protocol.MaxByteCount)
@ -2340,7 +2340,7 @@ var _ = Describe("Client Session", func() {
MaxIdleTimeout: 18 * time.Second, MaxIdleTimeout: 18 * time.Second,
} }
packer.EXPECT().HandleTransportParameters(gomock.Any()) packer.EXPECT().HandleTransportParameters(gomock.Any())
qlogger.EXPECT().ReceivedTransportParameters(params) tracer.EXPECT().ReceivedTransportParameters(params)
sess.processTransportParameters(params) sess.processTransportParameters(params)
Expect(sess.idleTimeout).To(Equal(18 * time.Second)) Expect(sess.idleTimeout).To(Equal(18 * time.Second))
}) })
@ -2353,7 +2353,7 @@ var _ = Describe("Client Session", func() {
StatelessResetToken: &[16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}, StatelessResetToken: &[16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16},
} }
expectClose() expectClose()
qlogger.EXPECT().ReceivedTransportParameters(params) tracer.EXPECT().ReceivedTransportParameters(params)
sess.processTransportParameters(params) sess.processTransportParameters(params)
Eventually(errChan).Should(Receive(MatchError("TRANSPORT_PARAMETER_ERROR: expected initial_source_connection_id to equal 0xdeadbeef, is 0xdecafbad"))) Eventually(errChan).Should(Receive(MatchError("TRANSPORT_PARAMETER_ERROR: expected initial_source_connection_id to equal 0xdeadbeef, is 0xdecafbad")))
}) })
@ -2366,7 +2366,7 @@ var _ = Describe("Client Session", func() {
StatelessResetToken: &[16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}, StatelessResetToken: &[16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16},
} }
expectClose() expectClose()
qlogger.EXPECT().ReceivedTransportParameters(params) tracer.EXPECT().ReceivedTransportParameters(params)
sess.processTransportParameters(params) sess.processTransportParameters(params)
Eventually(errChan).Should(Receive(MatchError("TRANSPORT_PARAMETER_ERROR: missing retry_source_connection_id"))) Eventually(errChan).Should(Receive(MatchError("TRANSPORT_PARAMETER_ERROR: missing retry_source_connection_id")))
}) })
@ -2380,7 +2380,7 @@ var _ = Describe("Client Session", func() {
StatelessResetToken: &[16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}, StatelessResetToken: &[16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16},
} }
expectClose() expectClose()
qlogger.EXPECT().ReceivedTransportParameters(params) tracer.EXPECT().ReceivedTransportParameters(params)
sess.processTransportParameters(params) sess.processTransportParameters(params)
Eventually(errChan).Should(Receive(MatchError("TRANSPORT_PARAMETER_ERROR: expected retry_source_connection_id to equal 0xdeadbeef, is 0xdeadc0de"))) Eventually(errChan).Should(Receive(MatchError("TRANSPORT_PARAMETER_ERROR: expected retry_source_connection_id to equal 0xdeadbeef, is 0xdeadc0de")))
}) })
@ -2393,7 +2393,7 @@ var _ = Describe("Client Session", func() {
StatelessResetToken: &[16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}, StatelessResetToken: &[16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16},
} }
expectClose() expectClose()
qlogger.EXPECT().ReceivedTransportParameters(params) tracer.EXPECT().ReceivedTransportParameters(params)
sess.processTransportParameters(params) sess.processTransportParameters(params)
Eventually(errChan).Should(Receive(MatchError("TRANSPORT_PARAMETER_ERROR: received retry_source_connection_id, although no Retry was performed"))) Eventually(errChan).Should(Receive(MatchError("TRANSPORT_PARAMETER_ERROR: received retry_source_connection_id, although no Retry was performed")))
}) })
@ -2406,7 +2406,7 @@ var _ = Describe("Client Session", func() {
StatelessResetToken: &[16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}, StatelessResetToken: &[16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16},
} }
expectClose() expectClose()
qlogger.EXPECT().ReceivedTransportParameters(params) tracer.EXPECT().ReceivedTransportParameters(params)
sess.processTransportParameters(params) sess.processTransportParameters(params)
Eventually(errChan).Should(Receive(MatchError("TRANSPORT_PARAMETER_ERROR: expected original_destination_connection_id to equal 0xdeadbeef, is 0xdecafbad"))) Eventually(errChan).Should(Receive(MatchError("TRANSPORT_PARAMETER_ERROR: expected original_destination_connection_id to equal 0xdeadbeef, is 0xdecafbad")))
}) })
@ -2471,10 +2471,10 @@ var _ = Describe("Client Session", func() {
hdr: hdr1, hdr: hdr1,
data: []byte{0}, // one PADDING frame data: []byte{0}, // one PADDING frame
}, nil) }, nil)
qlogger.EXPECT().ReceivedPacket(gomock.Any(), gomock.Any(), gomock.Any()) tracer.EXPECT().ReceivedPacket(gomock.Any(), gomock.Any(), gomock.Any())
Expect(sess.handlePacketImpl(getPacket(hdr1, nil))).To(BeTrue()) Expect(sess.handlePacketImpl(getPacket(hdr1, nil))).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.
qlogger.EXPECT().DroppedPacket(gomock.Any(), gomock.Any(), gomock.Any()) tracer.EXPECT().DroppedPacket(gomock.Any(), gomock.Any(), gomock.Any())
Expect(sess.handlePacketImpl(getPacket(hdr2, nil))).To(BeFalse()) Expect(sess.handlePacketImpl(getPacket(hdr2, nil))).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(logging.PacketType0RTT, protocol.ByteCount(len(p.data)), gomock.Any()) tracer.EXPECT().DroppedPacket(logging.PacketType0RTT, protocol.ByteCount(len(p.data)), gomock.Any())
Expect(sess.handlePacketImpl(p)).To(BeFalse()) Expect(sess.handlePacketImpl(p)).To(BeFalse())
}) })
@ -2499,7 +2499,7 @@ var _ = Describe("Client Session", func() {
It("fails on Initial-level ACK for unsent packet", func() { It("fails on Initial-level ACK for unsent packet", func() {
ackFrame := testutils.ComposeAckFrame(0, 0) ackFrame := testutils.ComposeAckFrame(0, 0)
initialPacket := testutils.ComposeInitialPacket(destConnID, srcConnID, sess.version, destConnID, []wire.Frame{ackFrame}) initialPacket := testutils.ComposeInitialPacket(destConnID, srcConnID, sess.version, destConnID, []wire.Frame{ackFrame})
qlogger.EXPECT().ReceivedPacket(gomock.Any(), gomock.Any(), gomock.Any()) tracer.EXPECT().ReceivedPacket(gomock.Any(), gomock.Any(), gomock.Any())
Expect(sess.handlePacketImpl(wrapPacket(initialPacket))).To(BeFalse()) Expect(sess.handlePacketImpl(wrapPacket(initialPacket))).To(BeFalse())
}) })
@ -2508,7 +2508,7 @@ var _ = Describe("Client Session", func() {
It("fails on Initial-level CONNECTION_CLOSE frame", func() { It("fails on Initial-level CONNECTION_CLOSE frame", func() {
connCloseFrame := testutils.ComposeConnCloseFrame() connCloseFrame := testutils.ComposeConnCloseFrame()
initialPacket := testutils.ComposeInitialPacket(destConnID, srcConnID, sess.version, destConnID, []wire.Frame{connCloseFrame}) initialPacket := testutils.ComposeInitialPacket(destConnID, srcConnID, sess.version, destConnID, []wire.Frame{connCloseFrame})
qlogger.EXPECT().ReceivedPacket(gomock.Any(), gomock.Any(), gomock.Any()) tracer.EXPECT().ReceivedPacket(gomock.Any(), gomock.Any(), gomock.Any())
Expect(sess.handlePacketImpl(wrapPacket(initialPacket))).To(BeTrue()) Expect(sess.handlePacketImpl(wrapPacket(initialPacket))).To(BeTrue())
}) })
@ -2523,10 +2523,10 @@ var _ = Describe("Client Session", func() {
cryptoSetup.EXPECT().ChangeConnectionID(newSrcConnID) cryptoSetup.EXPECT().ChangeConnectionID(newSrcConnID)
packer.EXPECT().SetToken([]byte("foobar")) packer.EXPECT().SetToken([]byte("foobar"))
qlogger.EXPECT().ReceivedRetry(gomock.Any()) tracer.EXPECT().ReceivedRetry(gomock.Any())
sess.handlePacketImpl(wrapPacket(testutils.ComposeRetryPacket(newSrcConnID, destConnID, destConnID, []byte("foobar"), sess.version))) sess.handlePacketImpl(wrapPacket(testutils.ComposeRetryPacket(newSrcConnID, destConnID, destConnID, []byte("foobar"), sess.version)))
initialPacket := testutils.ComposeInitialPacket(sess.connIDManager.Get(), srcConnID, sess.version, sess.connIDManager.Get(), nil) initialPacket := testutils.ComposeInitialPacket(sess.connIDManager.Get(), srcConnID, sess.version, sess.connIDManager.Get(), nil)
qlogger.EXPECT().DroppedPacket(gomock.Any(), gomock.Any(), gomock.Any()) tracer.EXPECT().DroppedPacket(gomock.Any(), gomock.Any(), gomock.Any())
Expect(sess.handlePacketImpl(wrapPacket(initialPacket))).To(BeFalse()) Expect(sess.handlePacketImpl(wrapPacket(initialPacket))).To(BeFalse())
}) })