github.com/ooni/psiphon/tunnel-core@v0.0.0-20230105123940-fe12a24c96ee/oovendor/quic-go/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  	"context"
     7  	"net"
     8  	"time"
     9  
    10  	"github.com/ooni/psiphon/tunnel-core/oovendor/quic-go/internal/utils"
    11  
    12  	"github.com/ooni/psiphon/tunnel-core/oovendor/quic-go/internal/protocol"
    13  	"github.com/ooni/psiphon/tunnel-core/oovendor/quic-go/internal/qerr"
    14  	"github.com/ooni/psiphon/tunnel-core/oovendor/quic-go/internal/wire"
    15  )
    16  
    17  type (
    18  	// A ByteCount is used to count bytes.
    19  	ByteCount = protocol.ByteCount
    20  	// A ConnectionID is a QUIC Connection ID.
    21  	ConnectionID = protocol.ConnectionID
    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 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  // A Tracer traces events.
    94  type Tracer interface {
    95  	// TracerForConnection requests a new tracer for a connection.
    96  	// The ODCID is the original destination connection ID:
    97  	// The destination connection ID that the client used on the first Initial packet it sent on this connection.
    98  	// If nil is returned, tracing will be disabled for this connection.
    99  	TracerForConnection(ctx context.Context, p Perspective, odcid ConnectionID) ConnectionTracer
   100  
   101  	SentPacket(net.Addr, *Header, ByteCount, []Frame)
   102  	DroppedPacket(net.Addr, PacketType, ByteCount, PacketDropReason)
   103  }
   104  
   105  // A ConnectionTracer records events.
   106  type ConnectionTracer interface {
   107  	StartedConnection(local, remote net.Addr, srcConnID, destConnID ConnectionID)
   108  	NegotiatedVersion(chosen VersionNumber, clientVersions, serverVersions []VersionNumber)
   109  	ClosedConnection(error)
   110  	SentTransportParameters(*TransportParameters)
   111  	ReceivedTransportParameters(*TransportParameters)
   112  	RestoredTransportParameters(parameters *TransportParameters) // for 0-RTT
   113  	SentPacket(hdr *ExtendedHeader, size ByteCount, ack *AckFrame, frames []Frame)
   114  	ReceivedVersionNegotiationPacket(*Header, []VersionNumber)
   115  	ReceivedRetry(*Header)
   116  	ReceivedPacket(hdr *ExtendedHeader, size ByteCount, frames []Frame)
   117  	BufferedPacket(PacketType)
   118  	DroppedPacket(PacketType, ByteCount, PacketDropReason)
   119  	UpdatedMetrics(rttStats *RTTStats, cwnd, bytesInFlight ByteCount, packetsInFlight int)
   120  	AcknowledgedPacket(EncryptionLevel, PacketNumber)
   121  	LostPacket(EncryptionLevel, PacketNumber, PacketLossReason)
   122  	UpdatedCongestionState(CongestionState)
   123  	UpdatedPTOCount(value uint32)
   124  	UpdatedKeyFromTLS(EncryptionLevel, Perspective)
   125  	UpdatedKey(generation KeyPhase, remote bool)
   126  	DroppedEncryptionLevel(EncryptionLevel)
   127  	DroppedKey(generation KeyPhase)
   128  	SetLossTimer(TimerType, EncryptionLevel, time.Time)
   129  	LossTimerExpired(TimerType, EncryptionLevel)
   130  	LossTimerCanceled()
   131  	// Close is called when the connection is closed.
   132  	Close()
   133  	Debug(name, msg string)
   134  }