mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-04 12:47:36 +03:00
only set the 0x80 bit to 1 for version negotiation packets
This commit is contained in:
parent
ba4194153e
commit
c720250b9b
2 changed files with 1 additions and 2 deletions
|
@ -15,7 +15,7 @@ func ComposeVersionNegotiation(destConnID, srcConnID protocol.ConnectionID, vers
|
||||||
buf := bytes.NewBuffer(make([]byte, 0, expectedLen))
|
buf := bytes.NewBuffer(make([]byte, 0, expectedLen))
|
||||||
r := make([]byte, 1)
|
r := make([]byte, 1)
|
||||||
_, _ = rand.Read(r) // ignore the error here. It is not critical to have perfect random here.
|
_, _ = rand.Read(r) // ignore the error here. It is not critical to have perfect random here.
|
||||||
buf.WriteByte(r[0] | 0xc0)
|
buf.WriteByte(r[0] | 0x80)
|
||||||
utils.BigEndian.WriteUint32(buf, 0) // version 0
|
utils.BigEndian.WriteUint32(buf, 0) // version 0
|
||||||
buf.WriteByte(uint8(destConnID.Len()))
|
buf.WriteByte(uint8(destConnID.Len()))
|
||||||
buf.Write(destConnID)
|
buf.Write(destConnID)
|
||||||
|
|
|
@ -14,7 +14,6 @@ var _ = Describe("Version Negotiation Packets", func() {
|
||||||
data, err := ComposeVersionNegotiation(destConnID, srcConnID, versions)
|
data, err := ComposeVersionNegotiation(destConnID, srcConnID, versions)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(data[0] & 0x80).ToNot(BeZero())
|
Expect(data[0] & 0x80).ToNot(BeZero())
|
||||||
Expect(data[0] & 0x40).ToNot(BeZero())
|
|
||||||
hdr, _, rest, err := ParsePacket(data, 4)
|
hdr, _, rest, err := ParsePacket(data, 4)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(hdr.DestConnectionID).To(Equal(destConnID))
|
Expect(hdr.DestConnectionID).To(Equal(destConnID))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue