Skip to content

Commit

Permalink
Fixes a bug in ack frame generation involving duplicate packet numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
mpiraux committed Mar 24, 2019
1 parent 5d20fb6 commit 0f4ef1b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,22 @@ func (c *Connection) ProcessVersionNegotation(vn *VersionNegotiationPacket) erro
}
func (c *Connection) GetAckFrame(space PNSpace) *AckFrame { // Returns an ack frame based on the packet numbers received
sort.Sort(PacketNumberQueue(c.AckQueue[space]))
packetNumbers := c.AckQueue[space]
packetNumbers := make([]PacketNumber, 0, len(c.AckQueue[space]))
if len(c.AckQueue[space]) > 0 {
last := c.AckQueue[space][0]
packetNumbers = append(packetNumbers, last)
for _, i := range c.AckQueue[space] {
if i != last {
last = i
packetNumbers = append(packetNumbers, i)
}
}
}

if len(packetNumbers) == 0 {
return nil
}

frame := new(AckFrame)
frame.AckRanges = make([]AckRange, 0, 255)
frame.LargestAcknowledged = packetNumbers[0]
Expand Down

0 comments on commit 0f4ef1b

Please sign in to comment.