forked from quic-go/quic-go
Merge pull request #1166 from lucas-clemente/fix-1163
retransmit Initial packets as Initial packets
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
|||||||
// +gen linkedlist
|
// +gen linkedlist
|
||||||
type Packet struct {
|
type Packet struct {
|
||||||
PacketNumber protocol.PacketNumber
|
PacketNumber protocol.PacketNumber
|
||||||
|
PacketType protocol.PacketType
|
||||||
Frames []wire.Frame
|
Frames []wire.Frame
|
||||||
Length protocol.ByteCount
|
Length protocol.ByteCount
|
||||||
EncryptionLevel protocol.EncryptionLevel
|
EncryptionLevel protocol.EncryptionLevel
|
||||||
|
|||||||
@@ -108,6 +108,10 @@ func (p *packetPacker) PackHandshakeRetransmission(packet *ackhandler.Packet) (*
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
// make sure that the retransmission for an Initial packet is sent as an Initial packet
|
||||||
|
if packet.PacketType == protocol.PacketTypeInitial {
|
||||||
|
p.hasSentPacket = false
|
||||||
|
}
|
||||||
header := p.getHeader(packet.EncryptionLevel)
|
header := p.getHeader(packet.EncryptionLevel)
|
||||||
var frames []wire.Frame
|
var frames []wire.Frame
|
||||||
if !p.version.UsesIETFFrameFormat() { // for gQUIC: pack a STOP_WAITING first
|
if !p.version.UsesIETFFrameFormat() { // for gQUIC: pack a STOP_WAITING first
|
||||||
|
|||||||
@@ -703,6 +703,21 @@ var _ = Describe("Packet packer", func() {
|
|||||||
Expect(sf.DataLenPresent).To(BeTrue())
|
Expect(sf.DataLenPresent).To(BeTrue())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("packs a retransmission for an Initial packet", func() {
|
||||||
|
packer.version = versionIETFFrames
|
||||||
|
packer.perspective = protocol.PerspectiveClient
|
||||||
|
packet := &ackhandler.Packet{
|
||||||
|
PacketType: protocol.PacketTypeInitial,
|
||||||
|
EncryptionLevel: protocol.EncryptionUnencrypted,
|
||||||
|
Frames: []wire.Frame{sf},
|
||||||
|
}
|
||||||
|
p, err := packer.PackHandshakeRetransmission(packet)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(p.frames).To(Equal([]wire.Frame{sf}))
|
||||||
|
Expect(p.encryptionLevel).To(Equal(protocol.EncryptionUnencrypted))
|
||||||
|
Expect(p.header.Type).To(Equal(protocol.PacketTypeInitial))
|
||||||
|
})
|
||||||
|
|
||||||
It("refuses to retransmit packets that were sent with forward-secure encryption", func() {
|
It("refuses to retransmit packets that were sent with forward-secure encryption", func() {
|
||||||
p := &ackhandler.Packet{
|
p := &ackhandler.Packet{
|
||||||
EncryptionLevel: protocol.EncryptionForwardSecure,
|
EncryptionLevel: protocol.EncryptionForwardSecure,
|
||||||
|
|||||||
Reference in New Issue
Block a user