forked from quic-go/quic-go
63 lines
1.1 KiB
Go
63 lines
1.1 KiB
Go
package qlog
|
|
|
|
import (
|
|
"fmt"
|
|
"strconv"
|
|
|
|
"github.com/lucas-clemente/quic-go/internal/protocol"
|
|
)
|
|
|
|
func toString(i int64) string {
|
|
return strconv.FormatInt(i, 10)
|
|
}
|
|
|
|
type versionNumber protocol.VersionNumber
|
|
|
|
func (v versionNumber) String() string {
|
|
return fmt.Sprintf("%x", uint32(v))
|
|
}
|
|
|
|
type streamType protocol.StreamType
|
|
|
|
func (s streamType) String() string {
|
|
switch protocol.StreamType(s) {
|
|
case protocol.StreamTypeUni:
|
|
return "unidirectional"
|
|
case protocol.StreamTypeBidi:
|
|
return "bidirectional"
|
|
default:
|
|
panic("unknown stream type")
|
|
}
|
|
}
|
|
|
|
type connectionID protocol.ConnectionID
|
|
|
|
func (c connectionID) String() string {
|
|
return fmt.Sprintf("%x", []byte(c))
|
|
}
|
|
|
|
// category is the qlog event category.
|
|
type category uint8
|
|
|
|
const (
|
|
categoryConnectivity category = iota
|
|
categoryTransport
|
|
categorySecurity
|
|
categoryRecovery
|
|
)
|
|
|
|
func (c category) String() string {
|
|
switch c {
|
|
case categoryConnectivity:
|
|
return "connectivity"
|
|
case categoryTransport:
|
|
return "transport"
|
|
case categorySecurity:
|
|
return "security"
|
|
case categoryRecovery:
|
|
return "recovery"
|
|
default:
|
|
panic("unknown category")
|
|
}
|
|
}
|