forked from quic-go/quic-go
Merge pull request #942 from lucas-clemente/fix-941
accept Public Resets without the RSEQ tag
This commit is contained in:
@@ -43,14 +43,15 @@ func ParsePublicReset(r *bytes.Reader) (*PublicReset, error) {
|
|||||||
return nil, errors.New("wrong public reset tag")
|
return nil, errors.New("wrong public reset tag")
|
||||||
}
|
}
|
||||||
|
|
||||||
rseq, ok := msg.Data[handshake.TagRSEQ]
|
// The RSEQ tag is mandatory according to the gQUIC wire spec.
|
||||||
if !ok {
|
// However, Google doesn't send RSEQ in their Public Resets.
|
||||||
return nil, errors.New("RSEQ missing")
|
// Therefore, we'll treat RSEQ as an optional field.
|
||||||
}
|
if rseq, ok := msg.Data[handshake.TagRSEQ]; ok {
|
||||||
if len(rseq) != 8 {
|
if len(rseq) != 8 {
|
||||||
return nil, errors.New("invalid RSEQ tag")
|
return nil, errors.New("invalid RSEQ tag")
|
||||||
}
|
}
|
||||||
pr.RejectedPacketNumber = protocol.PacketNumber(binary.LittleEndian.Uint64(rseq))
|
pr.RejectedPacketNumber = protocol.PacketNumber(binary.LittleEndian.Uint64(rseq))
|
||||||
|
}
|
||||||
|
|
||||||
rnon, ok := msg.Data[handshake.TagRNON]
|
rnon, ok := msg.Data[handshake.TagRNON]
|
||||||
if !ok {
|
if !ok {
|
||||||
@@ -60,6 +61,5 @@ func ParsePublicReset(r *bytes.Reader) (*PublicReset, error) {
|
|||||||
return nil, errors.New("invalid RNON tag")
|
return nil, errors.New("invalid RNON tag")
|
||||||
}
|
}
|
||||||
pr.Nonce = binary.LittleEndian.Uint64(rnon)
|
pr.Nonce = binary.LittleEndian.Uint64(rnon)
|
||||||
|
|
||||||
return &pr, nil
|
return &pr, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,13 +73,14 @@ var _ = Describe("public reset", func() {
|
|||||||
Expect(err).To(MatchError("invalid RNON tag"))
|
Expect(err).To(MatchError("invalid RNON tag"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("rejects packets missing the rejected packet number", func() {
|
It("accepts packets missing the rejected packet number", func() {
|
||||||
data := map[handshake.Tag][]byte{
|
data := map[handshake.Tag][]byte{
|
||||||
handshake.TagRNON: []byte{0xde, 0xad, 0xbe, 0xef, 0xca, 0xfe, 0x13, 0x37},
|
handshake.TagRNON: []byte{0xde, 0xad, 0xbe, 0xef, 0xca, 0xfe, 0x13, 0x37},
|
||||||
}
|
}
|
||||||
handshake.HandshakeMessage{Tag: handshake.TagPRST, Data: data}.Write(b)
|
handshake.HandshakeMessage{Tag: handshake.TagPRST, Data: data}.Write(b)
|
||||||
_, err := ParsePublicReset(bytes.NewReader(b.Bytes()))
|
pr, err := ParsePublicReset(bytes.NewReader(b.Bytes()))
|
||||||
Expect(err).To(MatchError("RSEQ missing"))
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(pr.Nonce).To(Equal(uint64(0x3713fecaefbeadde)))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("rejects packets with a wrong length rejected packet number", func() {
|
It("rejects packets with a wrong length rejected packet number", func() {
|
||||||
|
|||||||
Reference in New Issue
Block a user