github.com/tumi8/quic-go@v0.37.4-tum/logging/interface.go (about) 1 // Package logging defines a logging interface for quic-go. 2 // This package should not be considered stable 3 package logging 4 5 import ( 6 "net" 7 "time" 8 9 "github.com/tumi8/quic-go/noninternal/utils" 10 "github.com/tumi8/quic-go/noninternal/protocol" 11 "github.com/tumi8/quic-go/noninternal/qerr" 12 "github.com/tumi8/quic-go/noninternal/wire" 13 ) 14 15 type ( 16 // A ByteCount is used to count bytes. 17 ByteCount = protocol.ByteCount 18 // A ConnectionID is a QUIC Connection ID. 19 ConnectionID = protocol.ConnectionID 20 // An ArbitraryLenConnectionID is a QUIC Connection ID that can be up to 255 bytes long. 21 ArbitraryLenConnectionID = protocol.ArbitraryLenConnectionID 22 // The EncryptionLevel is the encryption level of a packet. 23 EncryptionLevel = protocol.EncryptionLevel 24 // The KeyPhase is the key phase of the 1-RTT keys. 25 KeyPhase = protocol.KeyPhase 26 // The KeyPhaseBit is the value of the key phase bit of the 1-RTT packets. 27 KeyPhaseBit = protocol.KeyPhaseBit 28 // The PacketNumber is the packet number of a packet. 29 PacketNumber = protocol.PacketNumber 30 // The Perspective is the role of a QUIC endpoint (client or server). 31 Perspective = protocol.Perspective 32 // A StatelessResetToken is a stateless reset token. 33 StatelessResetToken = protocol.StatelessResetToken 34 // The StreamID is the stream ID. 35 StreamID = protocol.StreamID 36 // The StreamNum is the number of the stream. 37 StreamNum = protocol.StreamNum 38 // The StreamType is the type of the stream (unidirectional or bidirectional). 39 StreamType = protocol.StreamType 40 // The VersionNumber is the QUIC version. 41 VersionNumber = protocol.VersionNumber 42 43 // The Header is the QUIC packet header, before removing header protection. 44 Header = wire.Header 45 // The ExtendedHeader is the QUIC Long Header packet header, after removing header protection. 46 ExtendedHeader = wire.ExtendedHeader 47 // The TransportParameters are QUIC transport parameters. 48 TransportParameters = wire.TransportParameters 49 // The PreferredAddress is the preferred address sent in the transport parameters. 50 PreferredAddress = wire.PreferredAddress 51 52 // A TransportError is a transport-level error code. 53 TransportError = qerr.TransportErrorCode 54 // An ApplicationError is an application-defined error code. 55 ApplicationError = qerr.TransportErrorCode 56 57 // The RTTStats contain statistics used by the congestion controller. 58 RTTStats = utils.RTTStats 59 ) 60 61 const ( 62 // KeyPhaseZero is key phase bit 0 63 KeyPhaseZero KeyPhaseBit = protocol.KeyPhaseZero 64 // KeyPhaseOne is key phase bit 1 65 KeyPhaseOne KeyPhaseBit = protocol.KeyPhaseOne 66 ) 67 68 const ( 69 // PerspectiveServer is used for a QUIC server 70 PerspectiveServer Perspective = protocol.PerspectiveServer 71 // PerspectiveClient is used for a QUIC client 72 PerspectiveClient Perspective = protocol.PerspectiveClient 73 ) 74 75 const ( 76 // EncryptionInitial is the Initial encryption level 77 EncryptionInitial EncryptionLevel = protocol.EncryptionInitial 78 // EncryptionHandshake is the Handshake encryption level 79 EncryptionHandshake EncryptionLevel = protocol.EncryptionHandshake 80 // Encryption1RTT is the 1-RTT encryption level 81 Encryption1RTT EncryptionLevel = protocol.Encryption1RTT 82 // Encryption0RTT is the 0-RTT encryption level 83 Encryption0RTT EncryptionLevel = protocol.Encryption0RTT 84 ) 85 86 const ( 87 // StreamTypeUni is a unidirectional stream 88 StreamTypeUni = protocol.StreamTypeUni 89 // StreamTypeBidi is a bidirectional stream 90 StreamTypeBidi = protocol.StreamTypeBidi 91 ) 92 93 // The ShortHeader is the QUIC Short Header packet header, after removing header protection. 94 type ShortHeader struct { 95 DestConnectionID ConnectionID 96 PacketNumber PacketNumber 97 PacketNumberLen protocol.PacketNumberLen 98 KeyPhase KeyPhaseBit 99 } 100 101 // A Tracer traces events. 102 type Tracer interface { 103 SentPacket(net.Addr, *Header, ByteCount, []Frame) 104 SentVersionNegotiationPacket(_ net.Addr, dest, src ArbitraryLenConnectionID, _ []VersionNumber) 105 DroppedPacket(net.Addr, PacketType, ByteCount, PacketDropReason) 106 } 107 108 // A ConnectionTracer records events. 109 type ConnectionTracer interface { 110 StartedConnection(local, remote net.Addr, srcConnID, destConnID ConnectionID) 111 NegotiatedVersion(chosen VersionNumber, clientVersions, serverVersions []VersionNumber) 112 ClosedConnection(error) 113 SentTransportParameters(*TransportParameters) 114 ReceivedTransportParameters(*TransportParameters) 115 RestoredTransportParameters(parameters *TransportParameters) // for 0-RTT 116 SentLongHeaderPacket(hdr *ExtendedHeader, size ByteCount, ack *AckFrame, frames []Frame) 117 SentShortHeaderPacket(hdr *ShortHeader, size ByteCount, ack *AckFrame, frames []Frame) 118 ReceivedVersionNegotiationPacket(dest, src ArbitraryLenConnectionID, _ []VersionNumber) 119 ReceivedRetry(*Header) 120 ReceivedLongHeaderPacket(hdr *ExtendedHeader, size ByteCount, frames []Frame) 121 ReceivedShortHeaderPacket(hdr *ShortHeader, size ByteCount, frames []Frame) 122 BufferedPacket(PacketType, ByteCount) 123 DroppedPacket(PacketType, ByteCount, PacketDropReason) 124 UpdatedMetrics(rttStats *RTTStats, cwnd, bytesInFlight ByteCount, packetsInFlight int) 125 AcknowledgedPacket(EncryptionLevel, PacketNumber) 126 LostPacket(EncryptionLevel, PacketNumber, PacketLossReason) 127 UpdatedCongestionState(CongestionState) 128 UpdatedPTOCount(value uint32) 129 UpdatedKeyFromTLS(EncryptionLevel, Perspective) 130 UpdatedKey(generation KeyPhase, remote bool) 131 DroppedEncryptionLevel(EncryptionLevel) 132 DroppedKey(generation KeyPhase) 133 SetLossTimer(TimerType, EncryptionLevel, time.Time) 134 LossTimerExpired(TimerType, EncryptionLevel) 135 LossTimerCanceled() 136 // Close is called when the connection is closed. 137 Close() 138 Debug(name, msg string) 139 }