forked from quic-go/quic-go
move all stringifation of qlog events to the qlog package
This commit is contained in:
@@ -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"))
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user