github.com/metacubex/quic-go@v0.44.1-0.20240520163451-20b689a59136/internal/mocks/logging/connection_tracer.go (about)

     1  //go:build !gomock && !generate
     2  
     3  package mocklogging
     4  
     5  import (
     6  	"net"
     7  	"time"
     8  
     9  	"github.com/metacubex/quic-go/internal/mocks/logging/internal"
    10  	"github.com/metacubex/quic-go/logging"
    11  
    12  	"go.uber.org/mock/gomock"
    13  )
    14  
    15  type MockConnectionTracer = internal.MockConnectionTracer
    16  
    17  func NewMockConnectionTracer(ctrl *gomock.Controller) (*logging.ConnectionTracer, *MockConnectionTracer) {
    18  	t := internal.NewMockConnectionTracer(ctrl)
    19  	return &logging.ConnectionTracer{
    20  		StartedConnection: func(local, remote net.Addr, srcConnID, destConnID logging.ConnectionID) {
    21  			t.StartedConnection(local, remote, srcConnID, destConnID)
    22  		},
    23  		NegotiatedVersion: func(chosen logging.VersionNumber, clientVersions, serverVersions []logging.VersionNumber) {
    24  			t.NegotiatedVersion(chosen, clientVersions, serverVersions)
    25  		},
    26  		ClosedConnection: func(e error) {
    27  			t.ClosedConnection(e)
    28  		},
    29  		SentTransportParameters: func(tp *logging.TransportParameters) {
    30  			t.SentTransportParameters(tp)
    31  		},
    32  		ReceivedTransportParameters: func(tp *logging.TransportParameters) {
    33  			t.ReceivedTransportParameters(tp)
    34  		},
    35  		RestoredTransportParameters: func(tp *logging.TransportParameters) {
    36  			t.RestoredTransportParameters(tp)
    37  		},
    38  		SentLongHeaderPacket: func(hdr *logging.ExtendedHeader, size logging.ByteCount, ecn logging.ECN, ack *logging.AckFrame, frames []logging.Frame) {
    39  			t.SentLongHeaderPacket(hdr, size, ecn, ack, frames)
    40  		},
    41  		SentShortHeaderPacket: func(hdr *logging.ShortHeader, size logging.ByteCount, ecn logging.ECN, ack *logging.AckFrame, frames []logging.Frame) {
    42  			t.SentShortHeaderPacket(hdr, size, ecn, ack, frames)
    43  		},
    44  		ReceivedVersionNegotiationPacket: func(dest, src logging.ArbitraryLenConnectionID, versions []logging.VersionNumber) {
    45  			t.ReceivedVersionNegotiationPacket(dest, src, versions)
    46  		},
    47  		ReceivedRetry: func(hdr *logging.Header) {
    48  			t.ReceivedRetry(hdr)
    49  		},
    50  		ReceivedLongHeaderPacket: func(hdr *logging.ExtendedHeader, size logging.ByteCount, ecn logging.ECN, frames []logging.Frame) {
    51  			t.ReceivedLongHeaderPacket(hdr, size, ecn, frames)
    52  		},
    53  		ReceivedShortHeaderPacket: func(hdr *logging.ShortHeader, size logging.ByteCount, ecn logging.ECN, frames []logging.Frame) {
    54  			t.ReceivedShortHeaderPacket(hdr, size, ecn, frames)
    55  		},
    56  		BufferedPacket: func(typ logging.PacketType, size logging.ByteCount) {
    57  			t.BufferedPacket(typ, size)
    58  		},
    59  		DroppedPacket: func(typ logging.PacketType, pn logging.PacketNumber, size logging.ByteCount, reason logging.PacketDropReason) {
    60  			t.DroppedPacket(typ, pn, size, reason)
    61  		},
    62  		UpdatedMetrics: func(rttStats *logging.RTTStats, cwnd, bytesInFlight logging.ByteCount, packetsInFlight int) {
    63  			t.UpdatedMetrics(rttStats, cwnd, bytesInFlight, packetsInFlight)
    64  		},
    65  		AcknowledgedPacket: func(encLevel logging.EncryptionLevel, pn logging.PacketNumber) {
    66  			t.AcknowledgedPacket(encLevel, pn)
    67  		},
    68  		LostPacket: func(encLevel logging.EncryptionLevel, pn logging.PacketNumber, reason logging.PacketLossReason) {
    69  			t.LostPacket(encLevel, pn, reason)
    70  		},
    71  		UpdatedMTU: func(mtu logging.ByteCount, done bool) {
    72  			t.UpdatedMTU(mtu, done)
    73  		},
    74  		UpdatedCongestionState: func(state logging.CongestionState) {
    75  			t.UpdatedCongestionState(state)
    76  		},
    77  		UpdatedPTOCount: func(value uint32) {
    78  			t.UpdatedPTOCount(value)
    79  		},
    80  		UpdatedKeyFromTLS: func(encLevel logging.EncryptionLevel, perspective logging.Perspective) {
    81  			t.UpdatedKeyFromTLS(encLevel, perspective)
    82  		},
    83  		UpdatedKey: func(generation logging.KeyPhase, remote bool) {
    84  			t.UpdatedKey(generation, remote)
    85  		},
    86  		DroppedEncryptionLevel: func(encLevel logging.EncryptionLevel) {
    87  			t.DroppedEncryptionLevel(encLevel)
    88  		},
    89  		DroppedKey: func(generation logging.KeyPhase) {
    90  			t.DroppedKey(generation)
    91  		},
    92  		SetLossTimer: func(typ logging.TimerType, encLevel logging.EncryptionLevel, exp time.Time) {
    93  			t.SetLossTimer(typ, encLevel, exp)
    94  		},
    95  		LossTimerExpired: func(typ logging.TimerType, encLevel logging.EncryptionLevel) {
    96  			t.LossTimerExpired(typ, encLevel)
    97  		},
    98  		LossTimerCanceled: func() {
    99  			t.LossTimerCanceled()
   100  		},
   101  		ECNStateUpdated: func(state logging.ECNState, trigger logging.ECNStateTrigger) {
   102  			t.ECNStateUpdated(state, trigger)
   103  		},
   104  		ChoseALPN: func(protocol string) {
   105  			t.ChoseALPN(protocol)
   106  		},
   107  		Close: func() {
   108  			t.Close()
   109  		},
   110  		Debug: func(name, msg string) {
   111  			t.Debug(name, msg)
   112  		},
   113  	}, t
   114  }