mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-04 04:37:36 +03:00
move all stringifation of qlog events to the qlog package
This commit is contained in:
parent
673a9f40e4
commit
d4dc08b208
8 changed files with 168 additions and 164 deletions
|
@ -1,11 +1,9 @@
|
|||
package logging
|
||||
|
||||
import (
|
||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||
)
|
||||
import "github.com/lucas-clemente/quic-go/internal/protocol"
|
||||
|
||||
// PacketType is the packet type of a QUIC packet
|
||||
type PacketType protocol.PacketType
|
||||
type PacketType = protocol.PacketType
|
||||
|
||||
const (
|
||||
// PacketTypeInitial is the packet type of an Initial packet
|
||||
|
@ -26,29 +24,6 @@ const (
|
|||
PacketTypeNotDetermined
|
||||
)
|
||||
|
||||
func (t PacketType) String() string {
|
||||
switch t {
|
||||
case PacketTypeInitial:
|
||||
return "initial"
|
||||
case PacketTypeHandshake:
|
||||
return "handshake"
|
||||
case PacketTypeRetry:
|
||||
return "retry"
|
||||
case PacketType0RTT:
|
||||
return "0RTT"
|
||||
case PacketTypeVersionNegotiation:
|
||||
return "version_negotiation"
|
||||
case PacketTypeStatelessReset:
|
||||
return "stateless_reset"
|
||||
case PacketType1RTT:
|
||||
return "1RTT"
|
||||
case PacketTypeNotDetermined:
|
||||
return ""
|
||||
default:
|
||||
panic("unknown packet type")
|
||||
}
|
||||
}
|
||||
|
||||
type PacketLossReason uint8
|
||||
|
||||
const (
|
||||
|
@ -58,17 +33,6 @@ const (
|
|||
PacketLossTimeThreshold
|
||||
)
|
||||
|
||||
func (r PacketLossReason) String() string {
|
||||
switch r {
|
||||
case PacketLossReorderingThreshold:
|
||||
return "reordering_threshold"
|
||||
case PacketLossTimeThreshold:
|
||||
return "time_threshold"
|
||||
default:
|
||||
panic("unknown loss reason")
|
||||
}
|
||||
}
|
||||
|
||||
type PacketDropReason uint8
|
||||
|
||||
const (
|
||||
|
@ -96,35 +60,6 @@ const (
|
|||
PacketDropDuplicate
|
||||
)
|
||||
|
||||
func (r PacketDropReason) String() string {
|
||||
switch r {
|
||||
case PacketDropKeyUnavailable:
|
||||
return "key_unavailable"
|
||||
case PacketDropUnknownConnectionID:
|
||||
return "unknown_connection_id"
|
||||
case PacketDropHeaderParseError:
|
||||
return "header_parse_error"
|
||||
case PacketDropPayloadDecryptError:
|
||||
return "payload_decrypt_error"
|
||||
case PacketDropProtocolViolation:
|
||||
return "protocol_violation"
|
||||
case PacketDropDOSPrevention:
|
||||
return "dos_prevention"
|
||||
case PacketDropUnsupportedVersion:
|
||||
return "unsupported_version"
|
||||
case PacketDropUnexpectedPacket:
|
||||
return "unexpected_packet"
|
||||
case PacketDropUnexpectedSourceConnectionID:
|
||||
return "unexpected_source_connection_id"
|
||||
case PacketDropUnexpectedVersion:
|
||||
return "unexpected_version"
|
||||
case PacketDropDuplicate:
|
||||
return "duplicate"
|
||||
default:
|
||||
panic("unknown packet drop reason")
|
||||
}
|
||||
}
|
||||
|
||||
// TimerType is the type of the loss detection timer
|
||||
type TimerType uint8
|
||||
|
||||
|
@ -135,17 +70,6 @@ const (
|
|||
TimerTypePTO
|
||||
)
|
||||
|
||||
func (t TimerType) String() string {
|
||||
switch t {
|
||||
case TimerTypeACK:
|
||||
return "ack"
|
||||
case TimerTypePTO:
|
||||
return "pto"
|
||||
default:
|
||||
panic("unknown timer type")
|
||||
}
|
||||
}
|
||||
|
||||
// CloseReason is the reason why a session is closed
|
||||
type CloseReason uint8
|
||||
|
||||
|
@ -157,14 +81,3 @@ const (
|
|||
// This reason is not defined in the qlog draft, but very useful for debugging.
|
||||
CloseReasonIdleTimeout
|
||||
)
|
||||
|
||||
func (r CloseReason) String() string {
|
||||
switch r {
|
||||
case CloseReasonHandshakeTimeout:
|
||||
return "handshake_timeout"
|
||||
case CloseReasonIdleTimeout:
|
||||
return "idle_timeout"
|
||||
default:
|
||||
panic("unknown close reason")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
package logging
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var _ = Describe("Types", func() {
|
||||
It("has a string representation for the packet type", func() {
|
||||
Expect(PacketTypeInitial.String()).To(Equal("initial"))
|
||||
Expect(PacketTypeHandshake.String()).To(Equal("handshake"))
|
||||
Expect(PacketType0RTT.String()).To(Equal("0RTT"))
|
||||
Expect(PacketType1RTT.String()).To(Equal("1RTT"))
|
||||
Expect(PacketTypeStatelessReset.String()).To(Equal("stateless_reset"))
|
||||
Expect(PacketTypeRetry.String()).To(Equal("retry"))
|
||||
Expect(PacketTypeVersionNegotiation.String()).To(Equal("version_negotiation"))
|
||||
Expect(PacketTypeNotDetermined.String()).To(BeEmpty())
|
||||
})
|
||||
|
||||
It("has a string representation for the packet drop reason", func() {
|
||||
Expect(PacketDropKeyUnavailable.String()).To(Equal("key_unavailable"))
|
||||
Expect(PacketDropUnknownConnectionID.String()).To(Equal("unknown_connection_id"))
|
||||
Expect(PacketDropHeaderParseError.String()).To(Equal("header_parse_error"))
|
||||
Expect(PacketDropPayloadDecryptError.String()).To(Equal("payload_decrypt_error"))
|
||||
Expect(PacketDropProtocolViolation.String()).To(Equal("protocol_violation"))
|
||||
Expect(PacketDropDOSPrevention.String()).To(Equal("dos_prevention"))
|
||||
Expect(PacketDropUnsupportedVersion.String()).To(Equal("unsupported_version"))
|
||||
Expect(PacketDropUnexpectedPacket.String()).To(Equal("unexpected_packet"))
|
||||
Expect(PacketDropUnexpectedSourceConnectionID.String()).To(Equal("unexpected_source_connection_id"))
|
||||
Expect(PacketDropUnexpectedVersion.String()).To(Equal("unexpected_version"))
|
||||
})
|
||||
|
||||
It("has a string representation for the timer type", func() {
|
||||
Expect(TimerTypeACK.String()).To(Equal("ack"))
|
||||
Expect(TimerTypePTO.String()).To(Equal("pto"))
|
||||
})
|
||||
|
||||
It("has a string representation for the close reason", func() {
|
||||
Expect(CloseReasonHandshakeTimeout.String()).To(Equal("handshake_timeout"))
|
||||
Expect(CloseReasonIdleTimeout.String()).To(Equal("idle_timeout"))
|
||||
})
|
||||
})
|
|
@ -94,7 +94,7 @@ func (e eventConnectionStarted) MarshalJSONObject(enc *gojay.Encoder) {
|
|||
}
|
||||
|
||||
type eventConnectionClosed struct {
|
||||
Reason logging.CloseReason
|
||||
Reason closeReason
|
||||
}
|
||||
|
||||
func (e eventConnectionClosed) Category() category { return categoryTransport }
|
||||
|
@ -107,7 +107,7 @@ func (e eventConnectionClosed) MarshalJSONObject(enc *gojay.Encoder) {
|
|||
}
|
||||
|
||||
type eventPacketSent struct {
|
||||
PacketType logging.PacketType
|
||||
PacketType packetType
|
||||
Header packetHeader
|
||||
Frames frames
|
||||
IsCoalesced bool
|
||||
|
@ -129,7 +129,7 @@ func (e eventPacketSent) MarshalJSONObject(enc *gojay.Encoder) {
|
|||
}
|
||||
|
||||
type eventPacketReceived struct {
|
||||
PacketType logging.PacketType
|
||||
PacketType packetType
|
||||
Header packetHeader
|
||||
Frames frames
|
||||
IsCoalesced bool
|
||||
|
@ -159,7 +159,7 @@ func (e eventRetryReceived) Name() string { return "packet_received" }
|
|||
func (e eventRetryReceived) IsNil() bool { return false }
|
||||
|
||||
func (e eventRetryReceived) MarshalJSONObject(enc *gojay.Encoder) {
|
||||
enc.StringKey("packet_type", logging.PacketTypeRetry.String())
|
||||
enc.StringKey("packet_type", packetType(logging.PacketTypeRetry).String())
|
||||
enc.ObjectKey("header", e.Header)
|
||||
}
|
||||
|
||||
|
@ -173,7 +173,7 @@ func (e eventVersionNegotiationReceived) Name() string { return "packet_re
|
|||
func (e eventVersionNegotiationReceived) IsNil() bool { return false }
|
||||
|
||||
func (e eventVersionNegotiationReceived) MarshalJSONObject(enc *gojay.Encoder) {
|
||||
enc.StringKey("packet_type", logging.PacketTypeVersionNegotiation.String())
|
||||
enc.StringKey("packet_type", packetType(logging.PacketTypeVersionNegotiation).String())
|
||||
enc.ObjectKey("header", e.Header)
|
||||
enc.ArrayKey("supported_versions", versions(e.SupportedVersions))
|
||||
}
|
||||
|
@ -187,12 +187,12 @@ func (e eventStatelessResetReceived) Name() string { return "packet_receiv
|
|||
func (e eventStatelessResetReceived) IsNil() bool { return false }
|
||||
|
||||
func (e eventStatelessResetReceived) MarshalJSONObject(enc *gojay.Encoder) {
|
||||
enc.StringKey("packet_type", logging.PacketTypeStatelessReset.String())
|
||||
enc.StringKey("packet_type", packetType(logging.PacketTypeStatelessReset).String())
|
||||
enc.StringKey("stateless_reset_token", fmt.Sprintf("%x", *e.Token))
|
||||
}
|
||||
|
||||
type eventPacketBuffered struct {
|
||||
PacketType logging.PacketType
|
||||
PacketType packetType
|
||||
}
|
||||
|
||||
func (e eventPacketBuffered) Category() category { return categoryTransport }
|
||||
|
@ -205,9 +205,9 @@ func (e eventPacketBuffered) MarshalJSONObject(enc *gojay.Encoder) {
|
|||
}
|
||||
|
||||
type eventPacketDropped struct {
|
||||
PacketType logging.PacketType
|
||||
PacketType packetType
|
||||
PacketSize protocol.ByteCount
|
||||
Trigger logging.PacketDropReason
|
||||
Trigger packetDropReason
|
||||
}
|
||||
|
||||
func (e eventPacketDropped) Category() category { return categoryTransport }
|
||||
|
@ -278,9 +278,9 @@ func (e eventUpdatedPTO) MarshalJSONObject(enc *gojay.Encoder) {
|
|||
}
|
||||
|
||||
type eventPacketLost struct {
|
||||
PacketType logging.PacketType
|
||||
PacketType packetType
|
||||
PacketNumber protocol.PacketNumber
|
||||
Trigger logging.PacketLossReason
|
||||
Trigger packetLossReason
|
||||
}
|
||||
|
||||
func (e eventPacketLost) Category() category { return categoryRecovery }
|
||||
|
@ -382,7 +382,7 @@ func (e eventTransportParameters) MarshalJSONObject(enc *gojay.Encoder) {
|
|||
}
|
||||
|
||||
type eventLossTimerSet struct {
|
||||
TimerType logging.TimerType
|
||||
TimerType timerType
|
||||
EncLevel protocol.EncryptionLevel
|
||||
Delta time.Duration
|
||||
}
|
||||
|
@ -399,7 +399,7 @@ func (e eventLossTimerSet) MarshalJSONObject(enc *gojay.Encoder) {
|
|||
}
|
||||
|
||||
type eventLossTimerExpired struct {
|
||||
TimerType logging.TimerType
|
||||
TimerType timerType
|
||||
EncLevel protocol.EncryptionLevel
|
||||
}
|
||||
|
||||
|
|
|
@ -7,19 +7,21 @@ import (
|
|||
"github.com/lucas-clemente/quic-go/logging"
|
||||
)
|
||||
|
||||
func getPacketTypeFromEncryptionLevel(encLevel protocol.EncryptionLevel) logging.PacketType {
|
||||
func getPacketTypeFromEncryptionLevel(encLevel protocol.EncryptionLevel) packetType {
|
||||
var t logging.PacketType
|
||||
switch encLevel {
|
||||
case protocol.EncryptionInitial:
|
||||
return logging.PacketTypeInitial
|
||||
t = logging.PacketTypeInitial
|
||||
case protocol.EncryptionHandshake:
|
||||
return logging.PacketTypeHandshake
|
||||
t = logging.PacketTypeHandshake
|
||||
case protocol.Encryption0RTT:
|
||||
return logging.PacketType0RTT
|
||||
t = logging.PacketType0RTT
|
||||
case protocol.Encryption1RTT:
|
||||
return logging.PacketType1RTT
|
||||
t = logging.PacketType1RTT
|
||||
default:
|
||||
panic("unknown encryption level")
|
||||
}
|
||||
return packetType(t)
|
||||
}
|
||||
|
||||
func transformHeader(hdr *wire.Header) *packetHeader {
|
||||
|
|
|
@ -16,10 +16,10 @@ import (
|
|||
|
||||
var _ = Describe("Packet Header", func() {
|
||||
It("determines the packet type from the encryption level", func() {
|
||||
Expect(getPacketTypeFromEncryptionLevel(protocol.EncryptionInitial)).To(Equal(logging.PacketTypeInitial))
|
||||
Expect(getPacketTypeFromEncryptionLevel(protocol.EncryptionHandshake)).To(Equal(logging.PacketTypeHandshake))
|
||||
Expect(getPacketTypeFromEncryptionLevel(protocol.Encryption0RTT)).To(Equal(logging.PacketType0RTT))
|
||||
Expect(getPacketTypeFromEncryptionLevel(protocol.Encryption1RTT)).To(Equal(logging.PacketType1RTT))
|
||||
Expect(getPacketTypeFromEncryptionLevel(protocol.EncryptionInitial)).To(BeEquivalentTo(logging.PacketTypeInitial))
|
||||
Expect(getPacketTypeFromEncryptionLevel(protocol.EncryptionHandshake)).To(BeEquivalentTo(logging.PacketTypeHandshake))
|
||||
Expect(getPacketTypeFromEncryptionLevel(protocol.Encryption0RTT)).To(BeEquivalentTo(logging.PacketType0RTT))
|
||||
Expect(getPacketTypeFromEncryptionLevel(protocol.Encryption1RTT)).To(BeEquivalentTo(logging.PacketType1RTT))
|
||||
})
|
||||
|
||||
Context("marshalling", func() {
|
||||
|
|
22
qlog/qlog.go
22
qlog/qlog.go
|
@ -159,7 +159,7 @@ func (t *connectionTracer) StartedConnection(local, remote net.Addr, version pro
|
|||
|
||||
func (t *connectionTracer) ClosedConnection(r logging.CloseReason) {
|
||||
t.mutex.Lock()
|
||||
t.recordEvent(time.Now(), &eventConnectionClosed{Reason: r})
|
||||
t.recordEvent(time.Now(), &eventConnectionClosed{Reason: closeReason(r)})
|
||||
t.mutex.Unlock()
|
||||
}
|
||||
|
||||
|
@ -216,7 +216,7 @@ func (t *connectionTracer) SentPacket(hdr *wire.ExtendedHeader, packetSize proto
|
|||
header.PacketSize = packetSize
|
||||
t.mutex.Lock()
|
||||
t.recordEvent(time.Now(), &eventPacketSent{
|
||||
PacketType: logging.PacketTypeFromHeader(&hdr.Header),
|
||||
PacketType: packetType(logging.PacketTypeFromHeader(&hdr.Header)),
|
||||
Header: header,
|
||||
Frames: fs,
|
||||
})
|
||||
|
@ -232,7 +232,7 @@ func (t *connectionTracer) ReceivedPacket(hdr *wire.ExtendedHeader, packetSize p
|
|||
header.PacketSize = packetSize
|
||||
t.mutex.Lock()
|
||||
t.recordEvent(time.Now(), &eventPacketReceived{
|
||||
PacketType: logging.PacketTypeFromHeader(&hdr.Header),
|
||||
PacketType: packetType(logging.PacketTypeFromHeader(&hdr.Header)),
|
||||
Header: header,
|
||||
Frames: fs,
|
||||
})
|
||||
|
@ -268,18 +268,18 @@ func (t *connectionTracer) ReceivedStatelessReset(token *[16]byte) {
|
|||
t.mutex.Unlock()
|
||||
}
|
||||
|
||||
func (t *connectionTracer) BufferedPacket(packetType logging.PacketType) {
|
||||
func (t *connectionTracer) BufferedPacket(pt logging.PacketType) {
|
||||
t.mutex.Lock()
|
||||
t.recordEvent(time.Now(), &eventPacketBuffered{PacketType: packetType})
|
||||
t.recordEvent(time.Now(), &eventPacketBuffered{PacketType: packetType(pt)})
|
||||
t.mutex.Unlock()
|
||||
}
|
||||
|
||||
func (t *connectionTracer) DroppedPacket(packetType logging.PacketType, size protocol.ByteCount, dropReason logging.PacketDropReason) {
|
||||
func (t *connectionTracer) DroppedPacket(pt logging.PacketType, size protocol.ByteCount, reason logging.PacketDropReason) {
|
||||
t.mutex.Lock()
|
||||
t.recordEvent(time.Now(), &eventPacketDropped{
|
||||
PacketType: packetType,
|
||||
PacketType: packetType(pt),
|
||||
PacketSize: size,
|
||||
Trigger: dropReason,
|
||||
Trigger: packetDropReason(reason),
|
||||
})
|
||||
t.mutex.Unlock()
|
||||
}
|
||||
|
@ -308,7 +308,7 @@ func (t *connectionTracer) LostPacket(encLevel protocol.EncryptionLevel, pn prot
|
|||
t.recordEvent(time.Now(), &eventPacketLost{
|
||||
PacketType: getPacketTypeFromEncryptionLevel(encLevel),
|
||||
PacketNumber: pn,
|
||||
Trigger: lossReason,
|
||||
Trigger: packetLossReason(lossReason),
|
||||
})
|
||||
t.mutex.Unlock()
|
||||
}
|
||||
|
@ -360,7 +360,7 @@ func (t *connectionTracer) SetLossTimer(tt logging.TimerType, encLevel protocol.
|
|||
t.mutex.Lock()
|
||||
now := time.Now()
|
||||
t.recordEvent(now, &eventLossTimerSet{
|
||||
TimerType: tt,
|
||||
TimerType: timerType(tt),
|
||||
EncLevel: encLevel,
|
||||
Delta: timeout.Sub(now),
|
||||
})
|
||||
|
@ -370,7 +370,7 @@ func (t *connectionTracer) SetLossTimer(tt logging.TimerType, encLevel protocol.
|
|||
func (t *connectionTracer) LossTimerExpired(tt logging.TimerType, encLevel protocol.EncryptionLevel) {
|
||||
t.mutex.Lock()
|
||||
t.recordEvent(time.Now(), &eventLossTimerExpired{
|
||||
TimerType: tt,
|
||||
TimerType: timerType(tt),
|
||||
EncLevel: encLevel,
|
||||
})
|
||||
t.mutex.Unlock()
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
|
||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||
"github.com/lucas-clemente/quic-go/internal/qerr"
|
||||
"github.com/lucas-clemente/quic-go/logging"
|
||||
)
|
||||
|
||||
type owner uint8
|
||||
|
@ -212,3 +213,98 @@ func (e transportError) String() string {
|
|||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
type packetType logging.PacketType
|
||||
|
||||
func (t packetType) String() string {
|
||||
switch logging.PacketType(t) {
|
||||
case logging.PacketTypeInitial:
|
||||
return "initial"
|
||||
case logging.PacketTypeHandshake:
|
||||
return "handshake"
|
||||
case logging.PacketTypeRetry:
|
||||
return "retry"
|
||||
case logging.PacketType0RTT:
|
||||
return "0RTT"
|
||||
case logging.PacketTypeVersionNegotiation:
|
||||
return "version_negotiation"
|
||||
case logging.PacketTypeStatelessReset:
|
||||
return "stateless_reset"
|
||||
case logging.PacketType1RTT:
|
||||
return "1RTT"
|
||||
case logging.PacketTypeNotDetermined:
|
||||
return ""
|
||||
default:
|
||||
panic("unknown packet type")
|
||||
}
|
||||
}
|
||||
|
||||
type packetLossReason logging.PacketLossReason
|
||||
|
||||
func (r packetLossReason) String() string {
|
||||
switch logging.PacketLossReason(r) {
|
||||
case logging.PacketLossReorderingThreshold:
|
||||
return "reordering_threshold"
|
||||
case logging.PacketLossTimeThreshold:
|
||||
return "time_threshold"
|
||||
default:
|
||||
panic("unknown loss reason")
|
||||
}
|
||||
}
|
||||
|
||||
type packetDropReason logging.PacketDropReason
|
||||
|
||||
func (r packetDropReason) String() string {
|
||||
switch logging.PacketDropReason(r) {
|
||||
case logging.PacketDropKeyUnavailable:
|
||||
return "key_unavailable"
|
||||
case logging.PacketDropUnknownConnectionID:
|
||||
return "unknown_connection_id"
|
||||
case logging.PacketDropHeaderParseError:
|
||||
return "header_parse_error"
|
||||
case logging.PacketDropPayloadDecryptError:
|
||||
return "payload_decrypt_error"
|
||||
case logging.PacketDropProtocolViolation:
|
||||
return "protocol_violation"
|
||||
case logging.PacketDropDOSPrevention:
|
||||
return "dos_prevention"
|
||||
case logging.PacketDropUnsupportedVersion:
|
||||
return "unsupported_version"
|
||||
case logging.PacketDropUnexpectedPacket:
|
||||
return "unexpected_packet"
|
||||
case logging.PacketDropUnexpectedSourceConnectionID:
|
||||
return "unexpected_source_connection_id"
|
||||
case logging.PacketDropUnexpectedVersion:
|
||||
return "unexpected_version"
|
||||
case logging.PacketDropDuplicate:
|
||||
return "duplicate"
|
||||
default:
|
||||
panic("unknown packet drop reason")
|
||||
}
|
||||
}
|
||||
|
||||
type timerType logging.TimerType
|
||||
|
||||
func (t timerType) String() string {
|
||||
switch logging.TimerType(t) {
|
||||
case logging.TimerTypeACK:
|
||||
return "ack"
|
||||
case logging.TimerTypePTO:
|
||||
return "pto"
|
||||
default:
|
||||
panic("unknown timer type")
|
||||
}
|
||||
}
|
||||
|
||||
type closeReason logging.CloseReason
|
||||
|
||||
func (r closeReason) String() string {
|
||||
switch logging.CloseReason(r) {
|
||||
case logging.CloseReasonHandshakeTimeout:
|
||||
return "handshake_timeout"
|
||||
case logging.CloseReasonIdleTimeout:
|
||||
return "idle_timeout"
|
||||
default:
|
||||
panic("unknown close reason")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import (
|
|||
|
||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||
"github.com/lucas-clemente/quic-go/internal/qerr"
|
||||
"github.com/lucas-clemente/quic-go/logging"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
@ -28,6 +29,40 @@ var _ = Describe("Types", func() {
|
|||
Expect(categorySecurity.String()).To(Equal("security"))
|
||||
})
|
||||
|
||||
It("has a string representation for the packet type", func() {
|
||||
Expect(packetType(logging.PacketTypeInitial).String()).To(Equal("initial"))
|
||||
Expect(packetType(logging.PacketTypeHandshake).String()).To(Equal("handshake"))
|
||||
Expect(packetType(logging.PacketType0RTT).String()).To(Equal("0RTT"))
|
||||
Expect(packetType(logging.PacketType1RTT).String()).To(Equal("1RTT"))
|
||||
Expect(packetType(logging.PacketTypeStatelessReset).String()).To(Equal("stateless_reset"))
|
||||
Expect(packetType(logging.PacketTypeRetry).String()).To(Equal("retry"))
|
||||
Expect(packetType(logging.PacketTypeVersionNegotiation).String()).To(Equal("version_negotiation"))
|
||||
Expect(packetType(logging.PacketTypeNotDetermined).String()).To(BeEmpty())
|
||||
})
|
||||
|
||||
It("has a string representation for the packet drop reason", func() {
|
||||
Expect(packetDropReason(logging.PacketDropKeyUnavailable).String()).To(Equal("key_unavailable"))
|
||||
Expect(packetDropReason(logging.PacketDropUnknownConnectionID).String()).To(Equal("unknown_connection_id"))
|
||||
Expect(packetDropReason(logging.PacketDropHeaderParseError).String()).To(Equal("header_parse_error"))
|
||||
Expect(packetDropReason(logging.PacketDropPayloadDecryptError).String()).To(Equal("payload_decrypt_error"))
|
||||
Expect(packetDropReason(logging.PacketDropProtocolViolation).String()).To(Equal("protocol_violation"))
|
||||
Expect(packetDropReason(logging.PacketDropDOSPrevention).String()).To(Equal("dos_prevention"))
|
||||
Expect(packetDropReason(logging.PacketDropUnsupportedVersion).String()).To(Equal("unsupported_version"))
|
||||
Expect(packetDropReason(logging.PacketDropUnexpectedPacket).String()).To(Equal("unexpected_packet"))
|
||||
Expect(packetDropReason(logging.PacketDropUnexpectedSourceConnectionID).String()).To(Equal("unexpected_source_connection_id"))
|
||||
Expect(packetDropReason(logging.PacketDropUnexpectedVersion).String()).To(Equal("unexpected_version"))
|
||||
})
|
||||
|
||||
It("has a string representation for the timer type", func() {
|
||||
Expect(timerType(logging.TimerTypeACK).String()).To(Equal("ack"))
|
||||
Expect(timerType(logging.TimerTypePTO).String()).To(Equal("pto"))
|
||||
})
|
||||
|
||||
It("has a string representation for the close reason", func() {
|
||||
Expect(closeReason(logging.CloseReasonHandshakeTimeout).String()).To(Equal("handshake_timeout"))
|
||||
Expect(closeReason(logging.CloseReasonIdleTimeout).String()).To(Equal("idle_timeout"))
|
||||
})
|
||||
|
||||
It("has a string representation for the key type", func() {
|
||||
Expect(encLevelToKeyType(protocol.EncryptionInitial, protocol.PerspectiveClient).String()).To(Equal("client_initial_secret"))
|
||||
Expect(encLevelToKeyType(protocol.EncryptionInitial, protocol.PerspectiveServer).String()).To(Equal("server_initial_secret"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue