/
types.go
80 lines (69 loc) · 1.76 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package metrics
import "github.com/lucas-clemente/quic-go/logging"
type perspective logging.Perspective
func (p perspective) String() string {
switch logging.Perspective(p) {
case logging.PerspectiveClient:
return "client"
case logging.PerspectiveServer:
return "server"
default:
panic("unknown perspective")
}
}
type encryptionLevel logging.EncryptionLevel
func (e encryptionLevel) String() string {
switch logging.EncryptionLevel(e) {
case logging.EncryptionInitial:
return "initial"
case logging.EncryptionHandshake:
return "handshake"
case logging.Encryption0RTT:
return "0-RTT"
case logging.Encryption1RTT:
return "1-RTT"
default:
panic("unknown encryption level")
}
}
type packetLossReason logging.PacketLossReason
func (r packetLossReason) String() string {
switch logging.PacketLossReason(r) {
case logging.PacketLossTimeThreshold:
return "time_threshold"
case logging.PacketLossReorderingThreshold:
return "reordering_threshold"
default:
panic("unknown packet loss reason")
}
}
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.PacketTypeVersionNegotiation:
return "version_negotiation"
case logging.PacketTypeRetry:
return "retry"
case logging.PacketType0RTT:
return "0-RTT"
case logging.PacketType1RTT:
return "1-RTT"
default:
panic("unknown packet type")
}
}
type timeoutReason logging.TimeoutReason
func (r timeoutReason) String() string {
switch logging.TimeoutReason(r) {
case logging.TimeoutReasonHandshake:
return "handshake_timeout"
case logging.TimeoutReasonIdle:
return "idle_timeout"
default:
panic("unknown timeout reason")
}
}