forked from quic-go/quic-go
trace arbitrary length Connection IDs for Version Negotiation packets
This commit is contained in:
@@ -20,6 +20,13 @@ func (c ArbitraryLenConnectionID) Bytes() []byte {
|
||||
return c
|
||||
}
|
||||
|
||||
func (c ArbitraryLenConnectionID) String() string {
|
||||
if c.Len() == 0 {
|
||||
return "(empty)"
|
||||
}
|
||||
return fmt.Sprintf("%x", c.Bytes())
|
||||
}
|
||||
|
||||
// A ConnectionID in QUIC
|
||||
type ConnectionID []byte
|
||||
|
||||
|
||||
@@ -119,5 +119,15 @@ var _ = Describe("Connection ID generation", func() {
|
||||
c := ArbitraryLenConnectionID(make([]byte, 156))
|
||||
Expect(c.Len()).To(Equal(156))
|
||||
})
|
||||
|
||||
It("has a string representation", func() {
|
||||
c := ArbitraryLenConnectionID([]byte{0xde, 0xad, 0xbe, 0xef, 0x42})
|
||||
Expect(c.String()).To(Equal("deadbeef42"))
|
||||
})
|
||||
|
||||
It("has a string representation for the default value", func() {
|
||||
var c ArbitraryLenConnectionID
|
||||
Expect(c.String()).To(Equal("(empty)"))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user