forked from quic-go/quic-go
retransmit Initial packets as Initial packets
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
// +gen linkedlist
|
||||
type Packet struct {
|
||||
PacketNumber protocol.PacketNumber
|
||||
PacketType protocol.PacketType
|
||||
Frames []wire.Frame
|
||||
Length protocol.ByteCount
|
||||
EncryptionLevel protocol.EncryptionLevel
|
||||
|
||||
@@ -108,6 +108,10 @@ func (p *packetPacker) PackHandshakeRetransmission(packet *ackhandler.Packet) (*
|
||||
if err != nil {
|
||||
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)
|
||||
var frames []wire.Frame
|
||||
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())
|
||||
})
|
||||
|
||||
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() {
|
||||
p := &ackhandler.Packet{
|
||||
EncryptionLevel: protocol.EncryptionForwardSecure,
|
||||
|
||||
Reference in New Issue
Block a user