diff --git a/logging/interface.go b/logging/interface.go index e925ba0d..0c754fd5 100644 --- a/logging/interface.go +++ b/logging/interface.go @@ -11,32 +11,90 @@ import ( "github.com/lucas-clemente/quic-go/internal/wire" ) +type ( + // A ByteCount is used to count bytes. + ByteCount = protocol.ByteCount + // A ConnectionID is a QUIC Connection ID. + ConnectionID = protocol.ConnectionID + // The EncryptionLevel is the encryption level of a packet. + EncryptionLevel = protocol.EncryptionLevel + // The KeyPhase is the key phase of the 1-RTT keys. + KeyPhase = protocol.KeyPhase + // The PacketNumber is the packet number of a packet. + PacketNumber = protocol.PacketNumber + // The Perspective is the role of a QUIC endpoint (client or server). + Perspective = protocol.Perspective + // The StreamID is the stream ID. + StreamID = protocol.StreamID + // The StreamNum is the number of the stream. + StreamNum = protocol.StreamNum + // The StreamType is the type of the stream (unidirectional or bidirectional). + StreamType = protocol.StreamType + // The VersionNumber is the QUIC version. + VersionNumber = protocol.VersionNumber + // The Header is the QUIC packet header, before removing header protection. + Header = wire.Header + // The ExtendedHeader is the QUIC packet header, after removing header protection. + ExtendedHeader = wire.ExtendedHeader + // The TransportParameters are QUIC transport parameters. + TransportParameters = wire.TransportParameters + + // The RTTStats contain statistics used by the congestion controller. + RTTStats = congestion.RTTStats +) + +const ( + // PerspectiveServer is used for a QUIC server + PerspectiveServer Perspective = protocol.PerspectiveServer + // PerspectiveClient is used for a QUIC client + PerspectiveClient Perspective = protocol.PerspectiveClient +) + +const ( + // EncryptionInitial is the Initial encryption level + EncryptionInitial EncryptionLevel = protocol.EncryptionInitial + // EncryptionHandshake is the Handshake encryption level + EncryptionHandshake EncryptionLevel = protocol.EncryptionHandshake + // Encryption1RTT is the 1-RTT encryption level + Encryption1RTT EncryptionLevel = protocol.Encryption1RTT + // Encryption0RTT is the 0-RTT encryption level + Encryption0RTT EncryptionLevel = protocol.Encryption0RTT +) + +const ( + // StreamTypeUni is a unidirectional stream + StreamTypeUni = protocol.StreamTypeUni + // StreamTypeBidi is a bidirectional stream + StreamTypeBidi = protocol.StreamTypeBidi +) + +// A Tracer traces events. type Tracer interface { - TracerForServer(odcid protocol.ConnectionID) ConnectionTracer - TracerForClient(odcid protocol.ConnectionID) ConnectionTracer + TracerForServer(odcid ConnectionID) ConnectionTracer + TracerForClient(odcid ConnectionID) ConnectionTracer } // A ConnectionTracer records events. type ConnectionTracer interface { - StartedConnection(local, remote net.Addr, version protocol.VersionNumber, srcConnID, destConnID protocol.ConnectionID) + StartedConnection(local, remote net.Addr, version VersionNumber, srcConnID, destConnID ConnectionID) ClosedConnection(CloseReason) - SentTransportParameters(*wire.TransportParameters) - ReceivedTransportParameters(*wire.TransportParameters) - SentPacket(hdr *wire.ExtendedHeader, packetSize protocol.ByteCount, ack *wire.AckFrame, frames []wire.Frame) - ReceivedVersionNegotiationPacket(*wire.Header) - ReceivedRetry(*wire.Header) - ReceivedPacket(hdr *wire.ExtendedHeader, packetSize protocol.ByteCount, frames []wire.Frame) + SentTransportParameters(*TransportParameters) + ReceivedTransportParameters(*TransportParameters) + SentPacket(hdr *ExtendedHeader, packetSize ByteCount, ack *wire.AckFrame, frames []wire.Frame) + ReceivedVersionNegotiationPacket(*Header) + ReceivedRetry(*Header) + ReceivedPacket(hdr *ExtendedHeader, packetSize ByteCount, frames []wire.Frame) ReceivedStatelessReset(token *[16]byte) BufferedPacket(PacketType) - DroppedPacket(PacketType, protocol.ByteCount, PacketDropReason) - UpdatedMetrics(rttStats *congestion.RTTStats, cwnd protocol.ByteCount, bytesInFLight protocol.ByteCount, packetsInFlight int) - LostPacket(protocol.EncryptionLevel, protocol.PacketNumber, PacketLossReason) + DroppedPacket(PacketType, ByteCount, PacketDropReason) + UpdatedMetrics(rttStats *RTTStats, cwnd ByteCount, bytesInFLight ByteCount, packetsInFlight int) + LostPacket(EncryptionLevel, PacketNumber, PacketLossReason) UpdatedPTOCount(value uint32) - UpdatedKeyFromTLS(protocol.EncryptionLevel, protocol.Perspective) - UpdatedKey(generation protocol.KeyPhase, remote bool) - DroppedEncryptionLevel(protocol.EncryptionLevel) - SetLossTimer(TimerType, protocol.EncryptionLevel, time.Time) - LossTimerExpired(TimerType, protocol.EncryptionLevel) + UpdatedKeyFromTLS(EncryptionLevel, Perspective) + UpdatedKey(generation KeyPhase, remote bool) + DroppedEncryptionLevel(EncryptionLevel) + SetLossTimer(TimerType, EncryptionLevel, time.Time) + LossTimerExpired(TimerType, EncryptionLevel) LossTimerCanceled() // Close is called when the connection is closed. Close() diff --git a/logging/packet_header.go b/logging/packet_header.go index abd72b06..287e0cc5 100644 --- a/logging/packet_header.go +++ b/logging/packet_header.go @@ -2,11 +2,10 @@ package logging import ( "github.com/lucas-clemente/quic-go/internal/protocol" - "github.com/lucas-clemente/quic-go/internal/wire" ) // PacketTypeFromHeader determines the packet type from a *wire.Header. -func PacketTypeFromHeader(hdr *wire.Header) PacketType { +func PacketTypeFromHeader(hdr *Header) PacketType { if !hdr.IsLongHeader { return PacketType1RTT } @@ -31,13 +30,13 @@ func PacketTypeFromHeader(hdr *wire.Header) PacketType { type PacketHeader struct { PacketType PacketType - PacketNumber protocol.PacketNumber - PayloadLength protocol.ByteCount + PacketNumber PacketNumber + PayloadLength ByteCount // Size of the QUIC packet (QUIC header + payload). // See https://github.com/quiclog/internet-drafts/issues/40. - PacketSize protocol.ByteCount + PacketSize ByteCount - Version protocol.VersionNumber - SrcConnectionID protocol.ConnectionID - DestConnectionID protocol.ConnectionID + Version VersionNumber + SrcConnectionID ConnectionID + DestConnectionID ConnectionID }