add a RestoredTransportParameters method to the logging interface

This commit is contained in:
Marten Seemann 2021-01-09 14:20:52 +08:00
parent 96dbfbc320
commit d04662a964
8 changed files with 44 additions and 0 deletions

View file

@ -65,6 +65,7 @@ func (t *connTracer) StartedConnection(local, remote net.Addr, version logging.V
func (t *connTracer) ClosedConnection(logging.CloseReason) {}
func (t *connTracer) SentTransportParameters(*logging.TransportParameters) {}
func (t *connTracer) ReceivedTransportParameters(*logging.TransportParameters) {}
func (t *connTracer) RestoredTransportParameters(*logging.TransportParameters) {}
func (t *connTracer) SentPacket(hdr *logging.ExtendedHeader, size logging.ByteCount, ack *logging.AckFrame, frames []logging.Frame) {
sentHeaders = append(sentHeaders, hdr)
}

View file

@ -207,6 +207,18 @@ func (mr *MockConnectionTracerMockRecorder) ReceivedVersionNegotiationPacket(arg
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReceivedVersionNegotiationPacket", reflect.TypeOf((*MockConnectionTracer)(nil).ReceivedVersionNegotiationPacket), arg0, arg1)
}
// RestoredTransportParameters mocks base method
func (m *MockConnectionTracer) RestoredTransportParameters(arg0 *wire.TransportParameters) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "RestoredTransportParameters", arg0)
}
// RestoredTransportParameters indicates an expected call of RestoredTransportParameters
func (mr *MockConnectionTracerMockRecorder) RestoredTransportParameters(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RestoredTransportParameters", reflect.TypeOf((*MockConnectionTracer)(nil).RestoredTransportParameters), arg0)
}
// SentPacket mocks base method
func (m *MockConnectionTracer) SentPacket(arg0 *wire.ExtendedHeader, arg1 protocol.ByteCount, arg2 *wire.AckFrame, arg3 []logging.Frame) {
m.ctrl.T.Helper()

View file

@ -107,6 +107,7 @@ type ConnectionTracer interface {
ClosedConnection(CloseReason)
SentTransportParameters(*TransportParameters)
ReceivedTransportParameters(*TransportParameters)
RestoredTransportParameters(parameters *TransportParameters) // for 0-RTT
SentPacket(hdr *ExtendedHeader, size ByteCount, ack *AckFrame, frames []Frame)
ReceivedVersionNegotiationPacket(*Header, []VersionNumber)
ReceivedRetry(*Header)

View file

@ -206,6 +206,18 @@ func (mr *MockConnectionTracerMockRecorder) ReceivedVersionNegotiationPacket(arg
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReceivedVersionNegotiationPacket", reflect.TypeOf((*MockConnectionTracer)(nil).ReceivedVersionNegotiationPacket), arg0, arg1)
}
// RestoredTransportParameters mocks base method
func (m *MockConnectionTracer) RestoredTransportParameters(arg0 *wire.TransportParameters) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "RestoredTransportParameters", arg0)
}
// RestoredTransportParameters indicates an expected call of RestoredTransportParameters
func (mr *MockConnectionTracerMockRecorder) RestoredTransportParameters(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RestoredTransportParameters", reflect.TypeOf((*MockConnectionTracer)(nil).RestoredTransportParameters), arg0)
}
// SentPacket mocks base method
func (m *MockConnectionTracer) SentPacket(arg0 *wire.ExtendedHeader, arg1 protocol.ByteCount, arg2 *wire.AckFrame, arg3 []Frame) {
m.ctrl.T.Helper()

View file

@ -84,6 +84,12 @@ func (m *connTracerMultiplexer) ReceivedTransportParameters(tp *TransportParamet
}
}
func (m *connTracerMultiplexer) RestoredTransportParameters(tp *TransportParameters) {
for _, t := range m.tracers {
t.RestoredTransportParameters(tp)
}
}
func (m *connTracerMultiplexer) SentPacket(hdr *ExtendedHeader, size ByteCount, ack *AckFrame, frames []Frame) {
for _, t := range m.tracers {
t.SentPacket(hdr, size, ack, frames)

View file

@ -126,6 +126,13 @@ var _ = Describe("Tracing", func() {
tracer.ReceivedTransportParameters(tp)
})
It("traces the RestoredTransportParameters event", func() {
tp := &wire.TransportParameters{InitialMaxData: 1337}
tr1.EXPECT().RestoredTransportParameters(tp)
tr2.EXPECT().RestoredTransportParameters(tp)
tracer.RestoredTransportParameters(tp)
})
It("traces the SentPacket event", func() {
hdr := &ExtendedHeader{Header: Header{DestConnectionID: ConnectionID{1, 2, 3}}}
ack := &AckFrame{AckRanges: []AckRange{{Smallest: 1, Largest: 10}}}

View file

@ -165,6 +165,7 @@ func (t *connTracer) ClosedConnection(r logging.CloseReason) {
}
func (t *connTracer) SentTransportParameters(*logging.TransportParameters) {}
func (t *connTracer) ReceivedTransportParameters(*logging.TransportParameters) {}
func (t *connTracer) RestoredTransportParameters(*logging.TransportParameters) {}
func (t *connTracer) SentPacket(hdr *logging.ExtendedHeader, _ logging.ByteCount, _ *logging.AckFrame, _ []logging.Frame) {
typ := logging.PacketTypeFromHeader(&hdr.Header)
if typ == logging.PacketType1RTT {

View file

@ -168,6 +168,10 @@ func (t *connectionTracer) ReceivedTransportParameters(tp *wire.TransportParamet
t.recordTransportParameters(t.perspective.Opposite(), tp)
}
func (t *connectionTracer) RestoredTransportParameters(tp *wire.TransportParameters) {
// TODO: implement
}
func (t *connectionTracer) recordTransportParameters(sentBy protocol.Perspective, tp *wire.TransportParameters) {
owner := ownerLocal
if sentBy != t.perspective {