forked from quic-go/quic-go
fix PublicHeader of VersionNegotiation and PublicReset packets
fixes #71
This commit is contained in:
@@ -50,7 +50,10 @@ func (h *PublicHeader) WritePublicHeader(b *bytes.Buffer) error {
|
||||
utils.WriteUint64(b, uint64(h.ConnectionID))
|
||||
}
|
||||
|
||||
utils.WriteUint48(b, uint64(h.PacketNumber)) // TODO: Send shorter packet number if possible
|
||||
if !h.ResetFlag && !h.VersionFlag {
|
||||
utils.WriteUint48(b, uint64(h.PacketNumber)) // TODO: Send shorter packet number if possible
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -97,6 +97,8 @@ var _ = Describe("Public Header", func() {
|
||||
PacketNumber: 2,
|
||||
}
|
||||
publicHeader.WritePublicHeader(b)
|
||||
// must be the first assertion
|
||||
Expect(b.Len()).To(Equal(1 + 8)) // 1 FlagByte + 8 ConnectionID
|
||||
firstByte, _ := b.ReadByte()
|
||||
Expect(firstByte & 0x01).To(Equal(uint8(1)))
|
||||
})
|
||||
@@ -109,6 +111,8 @@ var _ = Describe("Public Header", func() {
|
||||
PacketNumber: 2,
|
||||
}
|
||||
publicHeader.WritePublicHeader(b)
|
||||
// must be the first assertion
|
||||
Expect(b.Len()).To(Equal(1 + 8)) // 1 FlagByte + 8 ConnectionID
|
||||
firstByte, _ := b.ReadByte()
|
||||
Expect((firstByte & 0x02) >> 1).To(Equal(uint8(1)))
|
||||
})
|
||||
|
||||
@@ -47,7 +47,7 @@ var _ = Describe("Server", func() {
|
||||
|
||||
It("composes version negotiation packets", func() {
|
||||
expected := append(
|
||||
[]byte{0x3d, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0},
|
||||
[]byte{0x3d, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
|
||||
protocol.SupportedVersionsAsTags...,
|
||||
)
|
||||
Expect(composeVersionNegotiation(1)).To(Equal(expected))
|
||||
|
||||
Reference in New Issue
Block a user