mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-03 20:27:35 +03:00
packer: reduce number of calls to time.Now() when packing packets (#3815)
This commit is contained in:
parent
56432a8b79
commit
591ab1ab5e
5 changed files with 177 additions and 170 deletions
|
@ -1811,7 +1811,7 @@ func (s *connection) sendPackets() error {
|
||||||
s.windowUpdateQueue.QueueAll()
|
s.windowUpdateQueue.QueueAll()
|
||||||
|
|
||||||
if !s.handshakeConfirmed {
|
if !s.handshakeConfirmed {
|
||||||
packet, err := s.packer.PackCoalescedPacket(false, s.mtuDiscoverer.CurrentSize(), s.version)
|
packet, err := s.packer.PackCoalescedPacket(false, s.mtuDiscoverer.CurrentSize(), now, s.version)
|
||||||
if err != nil || packet == nil {
|
if err != nil || packet == nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -1928,8 +1928,9 @@ func (s *connection) resetPacingDeadline() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *connection) maybeSendAckOnlyPacket() error {
|
func (s *connection) maybeSendAckOnlyPacket() error {
|
||||||
|
now := time.Now()
|
||||||
if !s.handshakeConfirmed {
|
if !s.handshakeConfirmed {
|
||||||
packet, err := s.packer.PackCoalescedPacket(true, s.mtuDiscoverer.CurrentSize(), s.version)
|
packet, err := s.packer.PackCoalescedPacket(true, s.mtuDiscoverer.CurrentSize(), now, s.version)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -1940,8 +1941,7 @@ func (s *connection) maybeSendAckOnlyPacket() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
now := time.Now()
|
p, buf, err := s.packer.PackAckOnlyPacket(s.mtuDiscoverer.CurrentSize(), now, s.version)
|
||||||
p, buf, err := s.packer.PackAckOnlyPacket(s.mtuDiscoverer.CurrentSize(), s.version)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == errNothingToPack {
|
if err == errNothingToPack {
|
||||||
return nil
|
return nil
|
||||||
|
@ -1955,6 +1955,7 @@ func (s *connection) maybeSendAckOnlyPacket() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *connection) sendProbePacket(encLevel protocol.EncryptionLevel) error {
|
func (s *connection) sendProbePacket(encLevel protocol.EncryptionLevel) error {
|
||||||
|
now := time.Now()
|
||||||
// Queue probe packets until we actually send out a packet,
|
// Queue probe packets until we actually send out a packet,
|
||||||
// or until there are no more packets to queue.
|
// or until there are no more packets to queue.
|
||||||
var packet *coalescedPacket
|
var packet *coalescedPacket
|
||||||
|
@ -1963,7 +1964,7 @@ func (s *connection) sendProbePacket(encLevel protocol.EncryptionLevel) error {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
var err error
|
var err error
|
||||||
packet, err = s.packer.MaybePackProbePacket(encLevel, s.mtuDiscoverer.CurrentSize(), s.version)
|
packet, err = s.packer.MaybePackProbePacket(encLevel, s.mtuDiscoverer.CurrentSize(), now, s.version)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -1984,7 +1985,7 @@ func (s *connection) sendProbePacket(encLevel protocol.EncryptionLevel) error {
|
||||||
panic("unexpected encryption level")
|
panic("unexpected encryption level")
|
||||||
}
|
}
|
||||||
var err error
|
var err error
|
||||||
packet, err = s.packer.MaybePackProbePacket(encLevel, s.mtuDiscoverer.CurrentSize(), s.version)
|
packet, err = s.packer.MaybePackProbePacket(encLevel, s.mtuDiscoverer.CurrentSize(), now, s.version)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -1992,7 +1993,7 @@ func (s *connection) sendProbePacket(encLevel protocol.EncryptionLevel) error {
|
||||||
if packet == nil || (len(packet.longHdrPackets) == 0 && packet.shortHdrPacket == nil) {
|
if packet == nil || (len(packet.longHdrPackets) == 0 && packet.shortHdrPacket == nil) {
|
||||||
return fmt.Errorf("connection BUG: couldn't pack %s probe packet", encLevel)
|
return fmt.Errorf("connection BUG: couldn't pack %s probe packet", encLevel)
|
||||||
}
|
}
|
||||||
s.sendPackedCoalescedPacket(packet, time.Now())
|
s.sendPackedCoalescedPacket(packet, now)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2000,7 +2001,7 @@ func (s *connection) sendProbePacket(encLevel protocol.EncryptionLevel) error {
|
||||||
// If there was nothing to pack, the returned size is 0.
|
// If there was nothing to pack, the returned size is 0.
|
||||||
func (s *connection) appendPacket(buf *packetBuffer, maxSize protocol.ByteCount, now time.Time) (protocol.ByteCount, error) {
|
func (s *connection) appendPacket(buf *packetBuffer, maxSize protocol.ByteCount, now time.Time) (protocol.ByteCount, error) {
|
||||||
startLen := buf.Len()
|
startLen := buf.Len()
|
||||||
p, err := s.packer.AppendPacket(buf, maxSize, s.version)
|
p, err := s.packer.AppendPacket(buf, maxSize, now, s.version)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
@ -2043,14 +2044,14 @@ func (s *connection) sendConnectionClose(e error) ([]byte, error) {
|
||||||
var transportErr *qerr.TransportError
|
var transportErr *qerr.TransportError
|
||||||
var applicationErr *qerr.ApplicationError
|
var applicationErr *qerr.ApplicationError
|
||||||
if errors.As(e, &transportErr) {
|
if errors.As(e, &transportErr) {
|
||||||
packet, err = s.packer.PackConnectionClose(transportErr, s.mtuDiscoverer.CurrentSize(), s.version)
|
packet, err = s.packer.PackConnectionClose(transportErr, s.mtuDiscoverer.CurrentSize(), time.Now(), s.version)
|
||||||
} else if errors.As(e, &applicationErr) {
|
} else if errors.As(e, &applicationErr) {
|
||||||
packet, err = s.packer.PackApplicationClose(applicationErr, s.mtuDiscoverer.CurrentSize(), s.version)
|
packet, err = s.packer.PackApplicationClose(applicationErr, s.mtuDiscoverer.CurrentSize(), time.Now(), s.version)
|
||||||
} else {
|
} else {
|
||||||
packet, err = s.packer.PackConnectionClose(&qerr.TransportError{
|
packet, err = s.packer.PackConnectionClose(&qerr.TransportError{
|
||||||
ErrorCode: qerr.InternalError,
|
ErrorCode: qerr.InternalError,
|
||||||
ErrorMessage: fmt.Sprintf("connection BUG: unspecified error type (msg: %s)", e.Error()),
|
ErrorMessage: fmt.Sprintf("connection BUG: unspecified error type (msg: %s)", e.Error()),
|
||||||
}, s.mtuDiscoverer.CurrentSize(), s.version)
|
}, s.mtuDiscoverer.CurrentSize(), time.Now(), s.version)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -87,7 +87,7 @@ var _ = Describe("Connection", func() {
|
||||||
}
|
}
|
||||||
|
|
||||||
expectAppendPacket := func(packer *MockPacker, p shortHeaderPacket, b []byte) *gomock.Call {
|
expectAppendPacket := func(packer *MockPacker, p shortHeaderPacket, b []byte) *gomock.Call {
|
||||||
return packer.EXPECT().AppendPacket(gomock.Any(), gomock.Any(), Version1).DoAndReturn(func(buf *packetBuffer, _ protocol.ByteCount, _ protocol.VersionNumber) (shortHeaderPacket, error) {
|
return packer.EXPECT().AppendPacket(gomock.Any(), gomock.Any(), gomock.Any(), Version1).DoAndReturn(func(buf *packetBuffer, _ protocol.ByteCount, _ time.Time, _ protocol.VersionNumber) (shortHeaderPacket, error) {
|
||||||
buf.Data = append(buf.Data, b...)
|
buf.Data = append(buf.Data, b...)
|
||||||
return p, nil
|
return p, nil
|
||||||
})
|
})
|
||||||
|
@ -448,7 +448,7 @@ var _ = Describe("Connection", func() {
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
buffer := getPacketBuffer()
|
buffer := getPacketBuffer()
|
||||||
buffer.Data = append(buffer.Data, []byte("connection close")...)
|
buffer.Data = append(buffer.Data, []byte("connection close")...)
|
||||||
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), conn.version).DoAndReturn(func(e *qerr.ApplicationError, _ protocol.ByteCount, _ protocol.VersionNumber) (*coalescedPacket, error) {
|
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), gomock.Any(), conn.version).DoAndReturn(func(e *qerr.ApplicationError, _ protocol.ByteCount, _ time.Time, _ protocol.VersionNumber) (*coalescedPacket, error) {
|
||||||
Expect(e.ErrorCode).To(BeEquivalentTo(qerr.NoError))
|
Expect(e.ErrorCode).To(BeEquivalentTo(qerr.NoError))
|
||||||
Expect(e.ErrorMessage).To(BeEmpty())
|
Expect(e.ErrorMessage).To(BeEmpty())
|
||||||
return &coalescedPacket{buffer: buffer}, nil
|
return &coalescedPacket{buffer: buffer}, nil
|
||||||
|
@ -473,7 +473,7 @@ var _ = Describe("Connection", func() {
|
||||||
streamManager.EXPECT().CloseWithError(gomock.Any())
|
streamManager.EXPECT().CloseWithError(gomock.Any())
|
||||||
expectReplaceWithClosed()
|
expectReplaceWithClosed()
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
||||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
||||||
tracer.EXPECT().ClosedConnection(gomock.Any())
|
tracer.EXPECT().ClosedConnection(gomock.Any())
|
||||||
tracer.EXPECT().Close()
|
tracer.EXPECT().Close()
|
||||||
|
@ -492,7 +492,7 @@ var _ = Describe("Connection", func() {
|
||||||
streamManager.EXPECT().CloseWithError(expectedErr)
|
streamManager.EXPECT().CloseWithError(expectedErr)
|
||||||
expectReplaceWithClosed()
|
expectReplaceWithClosed()
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
packer.EXPECT().PackApplicationClose(expectedErr, gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
packer.EXPECT().PackApplicationClose(expectedErr, gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
||||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
||||||
gomock.InOrder(
|
gomock.InOrder(
|
||||||
tracer.EXPECT().ClosedConnection(expectedErr),
|
tracer.EXPECT().ClosedConnection(expectedErr),
|
||||||
|
@ -513,7 +513,7 @@ var _ = Describe("Connection", func() {
|
||||||
streamManager.EXPECT().CloseWithError(expectedErr)
|
streamManager.EXPECT().CloseWithError(expectedErr)
|
||||||
expectReplaceWithClosed()
|
expectReplaceWithClosed()
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
packer.EXPECT().PackConnectionClose(expectedErr, gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
packer.EXPECT().PackConnectionClose(expectedErr, gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
||||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
||||||
gomock.InOrder(
|
gomock.InOrder(
|
||||||
tracer.EXPECT().ClosedConnection(expectedErr),
|
tracer.EXPECT().ClosedConnection(expectedErr),
|
||||||
|
@ -553,7 +553,7 @@ var _ = Describe("Connection", func() {
|
||||||
streamManager.EXPECT().CloseWithError(gomock.Any())
|
streamManager.EXPECT().CloseWithError(gomock.Any())
|
||||||
expectReplaceWithClosed()
|
expectReplaceWithClosed()
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
||||||
returned := make(chan struct{})
|
returned := make(chan struct{})
|
||||||
go func() {
|
go func() {
|
||||||
defer GinkgoRecover()
|
defer GinkgoRecover()
|
||||||
|
@ -621,7 +621,7 @@ var _ = Describe("Connection", func() {
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
conn.sentPacketHandler = sph
|
conn.sentPacketHandler = sph
|
||||||
expectAppendPacket(packer, shortHeaderPacket{Packet: &ackhandler.Packet{PacketNumber: 1}}, []byte("foobar"))
|
expectAppendPacket(packer, shortHeaderPacket{Packet: &ackhandler.Packet{PacketNumber: 1}}, []byte("foobar"))
|
||||||
packer.EXPECT().AppendPacket(gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, errNothingToPack).AnyTimes()
|
packer.EXPECT().AppendPacket(gomock.Any(), gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, errNothingToPack).AnyTimes()
|
||||||
runConn()
|
runConn()
|
||||||
conn.queueControlFrame(&wire.PingFrame{})
|
conn.queueControlFrame(&wire.PingFrame{})
|
||||||
conn.scheduleSending()
|
conn.scheduleSending()
|
||||||
|
@ -810,7 +810,7 @@ var _ = Describe("Connection", func() {
|
||||||
unpacker.EXPECT().UnpackLongHeader(gomock.Any(), gomock.Any(), gomock.Any(), conn.version).Return(nil, handshake.ErrDecryptionFailed)
|
unpacker.EXPECT().UnpackLongHeader(gomock.Any(), gomock.Any(), gomock.Any(), conn.version).Return(nil, handshake.ErrDecryptionFailed)
|
||||||
streamManager.EXPECT().CloseWithError(gomock.Any())
|
streamManager.EXPECT().CloseWithError(gomock.Any())
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
packer.EXPECT().PackConnectionClose(gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
packer.EXPECT().PackConnectionClose(gomock.Any(), gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
||||||
go func() {
|
go func() {
|
||||||
defer GinkgoRecover()
|
defer GinkgoRecover()
|
||||||
cryptoSetup.EXPECT().RunHandshake().MaxTimes(1)
|
cryptoSetup.EXPECT().RunHandshake().MaxTimes(1)
|
||||||
|
@ -847,7 +847,7 @@ var _ = Describe("Connection", func() {
|
||||||
}).Times(3)
|
}).Times(3)
|
||||||
tracer.EXPECT().ReceivedShortHeaderPacket(gomock.Any(), gomock.Any(), gomock.Any()).Do(func(hdr *logging.ShortHeader, _ protocol.ByteCount, _ []logging.Frame) {
|
tracer.EXPECT().ReceivedShortHeaderPacket(gomock.Any(), gomock.Any(), gomock.Any()).Do(func(hdr *logging.ShortHeader, _ protocol.ByteCount, _ []logging.Frame) {
|
||||||
}).Times(3)
|
}).Times(3)
|
||||||
packer.EXPECT().PackCoalescedPacket(false, gomock.Any(), conn.version) // only expect a single call
|
packer.EXPECT().PackCoalescedPacket(false, gomock.Any(), gomock.Any(), conn.version) // only expect a single call
|
||||||
|
|
||||||
for i := 0; i < 3; i++ {
|
for i := 0; i < 3; i++ {
|
||||||
conn.handlePacket(getShortHeaderPacket(srcConnID, 0x1337+protocol.PacketNumber(i), []byte("foobar")))
|
conn.handlePacket(getShortHeaderPacket(srcConnID, 0x1337+protocol.PacketNumber(i), []byte("foobar")))
|
||||||
|
@ -863,7 +863,7 @@ var _ = Describe("Connection", func() {
|
||||||
// make the go routine return
|
// make the go routine return
|
||||||
streamManager.EXPECT().CloseWithError(gomock.Any())
|
streamManager.EXPECT().CloseWithError(gomock.Any())
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
packer.EXPECT().PackConnectionClose(gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
packer.EXPECT().PackConnectionClose(gomock.Any(), gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
||||||
expectReplaceWithClosed()
|
expectReplaceWithClosed()
|
||||||
tracer.EXPECT().ClosedConnection(gomock.Any())
|
tracer.EXPECT().ClosedConnection(gomock.Any())
|
||||||
tracer.EXPECT().Close()
|
tracer.EXPECT().Close()
|
||||||
|
@ -882,7 +882,7 @@ var _ = Describe("Connection", func() {
|
||||||
}).Times(3)
|
}).Times(3)
|
||||||
tracer.EXPECT().ReceivedShortHeaderPacket(gomock.Any(), gomock.Any(), gomock.Any()).Do(func(hdr *logging.ShortHeader, _ protocol.ByteCount, _ []logging.Frame) {
|
tracer.EXPECT().ReceivedShortHeaderPacket(gomock.Any(), gomock.Any(), gomock.Any()).Do(func(hdr *logging.ShortHeader, _ protocol.ByteCount, _ []logging.Frame) {
|
||||||
}).Times(3)
|
}).Times(3)
|
||||||
packer.EXPECT().PackCoalescedPacket(false, gomock.Any(), conn.version).Times(3) // only expect a single call
|
packer.EXPECT().PackCoalescedPacket(false, gomock.Any(), gomock.Any(), conn.version).Times(3)
|
||||||
|
|
||||||
for i := 0; i < 3; i++ {
|
for i := 0; i < 3; i++ {
|
||||||
conn.handlePacket(getShortHeaderPacket(srcConnID, 0x1337+protocol.PacketNumber(i), []byte("foobar")))
|
conn.handlePacket(getShortHeaderPacket(srcConnID, 0x1337+protocol.PacketNumber(i), []byte("foobar")))
|
||||||
|
@ -898,7 +898,7 @@ var _ = Describe("Connection", func() {
|
||||||
// make the go routine return
|
// make the go routine return
|
||||||
streamManager.EXPECT().CloseWithError(gomock.Any())
|
streamManager.EXPECT().CloseWithError(gomock.Any())
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
packer.EXPECT().PackConnectionClose(gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
packer.EXPECT().PackConnectionClose(gomock.Any(), gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
||||||
expectReplaceWithClosed()
|
expectReplaceWithClosed()
|
||||||
tracer.EXPECT().ClosedConnection(gomock.Any())
|
tracer.EXPECT().ClosedConnection(gomock.Any())
|
||||||
tracer.EXPECT().Close()
|
tracer.EXPECT().Close()
|
||||||
|
@ -911,7 +911,7 @@ var _ = Describe("Connection", func() {
|
||||||
unpacker.EXPECT().UnpackShortHeader(gomock.Any(), gomock.Any()).Return(protocol.PacketNumber(0), protocol.PacketNumberLen(0), protocol.KeyPhaseBit(0), nil, wire.ErrInvalidReservedBits)
|
unpacker.EXPECT().UnpackShortHeader(gomock.Any(), gomock.Any()).Return(protocol.PacketNumber(0), protocol.PacketNumberLen(0), protocol.KeyPhaseBit(0), nil, wire.ErrInvalidReservedBits)
|
||||||
streamManager.EXPECT().CloseWithError(gomock.Any())
|
streamManager.EXPECT().CloseWithError(gomock.Any())
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
packer.EXPECT().PackConnectionClose(gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
packer.EXPECT().PackConnectionClose(gomock.Any(), gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
||||||
done := make(chan struct{})
|
done := make(chan struct{})
|
||||||
go func() {
|
go func() {
|
||||||
defer GinkgoRecover()
|
defer GinkgoRecover()
|
||||||
|
@ -947,7 +947,7 @@ var _ = Describe("Connection", func() {
|
||||||
conn.handlePacket(getShortHeaderPacket(srcConnID, 0x42, nil))
|
conn.handlePacket(getShortHeaderPacket(srcConnID, 0x42, nil))
|
||||||
Consistently(runErr).ShouldNot(Receive())
|
Consistently(runErr).ShouldNot(Receive())
|
||||||
// make the go routine return
|
// make the go routine return
|
||||||
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
||||||
tracer.EXPECT().ClosedConnection(gomock.Any())
|
tracer.EXPECT().ClosedConnection(gomock.Any())
|
||||||
tracer.EXPECT().Close()
|
tracer.EXPECT().Close()
|
||||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
||||||
|
@ -959,7 +959,7 @@ var _ = Describe("Connection", func() {
|
||||||
unpacker.EXPECT().UnpackShortHeader(gomock.Any(), gomock.Any()).Return(protocol.PacketNumber(0), protocol.PacketNumberLen(0), protocol.KeyPhaseBit(0), nil, &qerr.TransportError{ErrorCode: qerr.ConnectionIDLimitError})
|
unpacker.EXPECT().UnpackShortHeader(gomock.Any(), gomock.Any()).Return(protocol.PacketNumber(0), protocol.PacketNumberLen(0), protocol.KeyPhaseBit(0), nil, &qerr.TransportError{ErrorCode: qerr.ConnectionIDLimitError})
|
||||||
streamManager.EXPECT().CloseWithError(gomock.Any())
|
streamManager.EXPECT().CloseWithError(gomock.Any())
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
packer.EXPECT().PackConnectionClose(gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
packer.EXPECT().PackConnectionClose(gomock.Any(), gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
||||||
done := make(chan struct{})
|
done := make(chan struct{})
|
||||||
go func() {
|
go func() {
|
||||||
defer GinkgoRecover()
|
defer GinkgoRecover()
|
||||||
|
@ -1184,7 +1184,7 @@ var _ = Describe("Connection", func() {
|
||||||
|
|
||||||
AfterEach(func() {
|
AfterEach(func() {
|
||||||
streamManager.EXPECT().CloseWithError(gomock.Any())
|
streamManager.EXPECT().CloseWithError(gomock.Any())
|
||||||
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
||||||
expectReplaceWithClosed()
|
expectReplaceWithClosed()
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
||||||
|
@ -1221,7 +1221,7 @@ var _ = Describe("Connection", func() {
|
||||||
KeyPhase: protocol.KeyPhaseOne,
|
KeyPhase: protocol.KeyPhaseOne,
|
||||||
}
|
}
|
||||||
expectAppendPacket(packer, p, []byte("foobar"))
|
expectAppendPacket(packer, p, []byte("foobar"))
|
||||||
packer.EXPECT().AppendPacket(gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, errNothingToPack).AnyTimes()
|
packer.EXPECT().AppendPacket(gomock.Any(), gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, errNothingToPack).AnyTimes()
|
||||||
sent := make(chan struct{})
|
sent := make(chan struct{})
|
||||||
sender.EXPECT().WouldBlock().AnyTimes()
|
sender.EXPECT().WouldBlock().AnyTimes()
|
||||||
sender.EXPECT().Send(gomock.Any(), gomock.Any()).Do(func(*packetBuffer, protocol.ByteCount) { close(sent) })
|
sender.EXPECT().Send(gomock.Any(), gomock.Any()).Do(func(*packetBuffer, protocol.ByteCount) { close(sent) })
|
||||||
|
@ -1238,7 +1238,7 @@ var _ = Describe("Connection", func() {
|
||||||
It("doesn't send packets if there's nothing to send", func() {
|
It("doesn't send packets if there's nothing to send", func() {
|
||||||
conn.handshakeConfirmed = true
|
conn.handshakeConfirmed = true
|
||||||
runConn()
|
runConn()
|
||||||
packer.EXPECT().AppendPacket(gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, errNothingToPack).AnyTimes()
|
packer.EXPECT().AppendPacket(gomock.Any(), gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, errNothingToPack).AnyTimes()
|
||||||
conn.receivedPacketHandler.ReceivedPacket(0x035e, protocol.ECNNon, protocol.Encryption1RTT, time.Now(), true)
|
conn.receivedPacketHandler.ReceivedPacket(0x035e, protocol.ECNNon, protocol.Encryption1RTT, time.Now(), true)
|
||||||
conn.scheduleSending()
|
conn.scheduleSending()
|
||||||
time.Sleep(50 * time.Millisecond) // make sure there are no calls to mconn.Write()
|
time.Sleep(50 * time.Millisecond) // make sure there are no calls to mconn.Write()
|
||||||
|
@ -1250,7 +1250,7 @@ var _ = Describe("Connection", func() {
|
||||||
sph.EXPECT().GetLossDetectionTimeout().AnyTimes()
|
sph.EXPECT().GetLossDetectionTimeout().AnyTimes()
|
||||||
sph.EXPECT().SendMode().Return(ackhandler.SendAck)
|
sph.EXPECT().SendMode().Return(ackhandler.SendAck)
|
||||||
done := make(chan struct{})
|
done := make(chan struct{})
|
||||||
packer.EXPECT().PackCoalescedPacket(true, gomock.Any(), conn.version).Do(func(bool, protocol.ByteCount, protocol.VersionNumber) { close(done) })
|
packer.EXPECT().PackCoalescedPacket(true, gomock.Any(), gomock.Any(), conn.version).Do(func(bool, protocol.ByteCount, time.Time, protocol.VersionNumber) { close(done) })
|
||||||
conn.sentPacketHandler = sph
|
conn.sentPacketHandler = sph
|
||||||
runConn()
|
runConn()
|
||||||
conn.scheduleSending()
|
conn.scheduleSending()
|
||||||
|
@ -1268,7 +1268,7 @@ var _ = Describe("Connection", func() {
|
||||||
fc := mocks.NewMockConnectionFlowController(mockCtrl)
|
fc := mocks.NewMockConnectionFlowController(mockCtrl)
|
||||||
fc.EXPECT().IsNewlyBlocked().Return(true, protocol.ByteCount(1337))
|
fc.EXPECT().IsNewlyBlocked().Return(true, protocol.ByteCount(1337))
|
||||||
expectAppendPacket(packer, shortHeaderPacket{Packet: &ackhandler.Packet{PacketNumber: 13}}, []byte("foobar"))
|
expectAppendPacket(packer, shortHeaderPacket{Packet: &ackhandler.Packet{PacketNumber: 13}}, []byte("foobar"))
|
||||||
packer.EXPECT().AppendPacket(gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, errNothingToPack).AnyTimes()
|
packer.EXPECT().AppendPacket(gomock.Any(), gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, errNothingToPack).AnyTimes()
|
||||||
conn.connFlowController = fc
|
conn.connFlowController = fc
|
||||||
runConn()
|
runConn()
|
||||||
sent := make(chan struct{})
|
sent := make(chan struct{})
|
||||||
|
@ -1321,7 +1321,7 @@ var _ = Describe("Connection", func() {
|
||||||
sph.EXPECT().SendMode().Return(ackhandler.SendNone)
|
sph.EXPECT().SendMode().Return(ackhandler.SendNone)
|
||||||
sph.EXPECT().QueueProbePacket(encLevel)
|
sph.EXPECT().QueueProbePacket(encLevel)
|
||||||
p := getCoalescedPacket(123, enc != protocol.Encryption1RTT)
|
p := getCoalescedPacket(123, enc != protocol.Encryption1RTT)
|
||||||
packer.EXPECT().MaybePackProbePacket(encLevel, gomock.Any(), conn.version).Return(p, nil)
|
packer.EXPECT().MaybePackProbePacket(encLevel, gomock.Any(), gomock.Any(), conn.version).Return(p, nil)
|
||||||
sph.EXPECT().SentPacket(gomock.Any()).Do(func(packet *ackhandler.Packet) {
|
sph.EXPECT().SentPacket(gomock.Any()).Do(func(packet *ackhandler.Packet) {
|
||||||
Expect(packet.PacketNumber).To(Equal(protocol.PacketNumber(123)))
|
Expect(packet.PacketNumber).To(Equal(protocol.PacketNumber(123)))
|
||||||
})
|
})
|
||||||
|
@ -1346,7 +1346,7 @@ var _ = Describe("Connection", func() {
|
||||||
sph.EXPECT().SendMode().Return(ackhandler.SendNone)
|
sph.EXPECT().SendMode().Return(ackhandler.SendNone)
|
||||||
sph.EXPECT().QueueProbePacket(encLevel).Return(false)
|
sph.EXPECT().QueueProbePacket(encLevel).Return(false)
|
||||||
p := getCoalescedPacket(123, enc != protocol.Encryption1RTT)
|
p := getCoalescedPacket(123, enc != protocol.Encryption1RTT)
|
||||||
packer.EXPECT().MaybePackProbePacket(encLevel, gomock.Any(), conn.version).Return(p, nil)
|
packer.EXPECT().MaybePackProbePacket(encLevel, gomock.Any(), gomock.Any(), conn.version).Return(p, nil)
|
||||||
sph.EXPECT().SentPacket(gomock.Any()).Do(func(packet *ackhandler.Packet) {
|
sph.EXPECT().SentPacket(gomock.Any()).Do(func(packet *ackhandler.Packet) {
|
||||||
Expect(packet.PacketNumber).To(Equal(protocol.PacketNumber(123)))
|
Expect(packet.PacketNumber).To(Equal(protocol.PacketNumber(123)))
|
||||||
})
|
})
|
||||||
|
@ -1390,7 +1390,7 @@ var _ = Describe("Connection", func() {
|
||||||
|
|
||||||
AfterEach(func() {
|
AfterEach(func() {
|
||||||
// make the go routine return
|
// make the go routine return
|
||||||
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
||||||
expectReplaceWithClosed()
|
expectReplaceWithClosed()
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
||||||
|
@ -1434,7 +1434,7 @@ var _ = Describe("Connection", func() {
|
||||||
rand.Read(payload2)
|
rand.Read(payload2)
|
||||||
expectAppendPacket(packer, shortHeaderPacket{Packet: &ackhandler.Packet{PacketNumber: 10}}, payload1)
|
expectAppendPacket(packer, shortHeaderPacket{Packet: &ackhandler.Packet{PacketNumber: 10}}, payload1)
|
||||||
expectAppendPacket(packer, shortHeaderPacket{Packet: &ackhandler.Packet{PacketNumber: 11}}, payload2)
|
expectAppendPacket(packer, shortHeaderPacket{Packet: &ackhandler.Packet{PacketNumber: 11}}, payload2)
|
||||||
packer.EXPECT().AppendPacket(gomock.Any(), gomock.Any(), gomock.Any()).Return(shortHeaderPacket{}, errNothingToPack)
|
packer.EXPECT().AppendPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(shortHeaderPacket{}, errNothingToPack)
|
||||||
sender.EXPECT().WouldBlock().AnyTimes()
|
sender.EXPECT().WouldBlock().AnyTimes()
|
||||||
sender.EXPECT().Send(gomock.Any(), conn.mtuDiscoverer.CurrentSize()).Do(func(b *packetBuffer, l protocol.ByteCount) {
|
sender.EXPECT().Send(gomock.Any(), conn.mtuDiscoverer.CurrentSize()).Do(func(b *packetBuffer, l protocol.ByteCount) {
|
||||||
Expect(b.Data).To(Equal(append(payload1, payload2...)))
|
Expect(b.Data).To(Equal(append(payload1, payload2...)))
|
||||||
|
@ -1476,7 +1476,7 @@ var _ = Describe("Connection", func() {
|
||||||
sph.EXPECT().SentPacket(gomock.Any())
|
sph.EXPECT().SentPacket(gomock.Any())
|
||||||
sph.EXPECT().SendMode().Return(ackhandler.SendAny).Times(2)
|
sph.EXPECT().SendMode().Return(ackhandler.SendAny).Times(2)
|
||||||
expectAppendPacket(packer, shortHeaderPacket{Packet: &ackhandler.Packet{PacketNumber: 10}}, []byte("packet10"))
|
expectAppendPacket(packer, shortHeaderPacket{Packet: &ackhandler.Packet{PacketNumber: 10}}, []byte("packet10"))
|
||||||
packer.EXPECT().AppendPacket(gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, errNothingToPack)
|
packer.EXPECT().AppendPacket(gomock.Any(), gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, errNothingToPack)
|
||||||
sender.EXPECT().WouldBlock().AnyTimes()
|
sender.EXPECT().WouldBlock().AnyTimes()
|
||||||
sender.EXPECT().Send(gomock.Any(), gomock.Any())
|
sender.EXPECT().Send(gomock.Any(), gomock.Any())
|
||||||
go func() {
|
go func() {
|
||||||
|
@ -1492,7 +1492,7 @@ var _ = Describe("Connection", func() {
|
||||||
sph.EXPECT().SentPacket(gomock.Any())
|
sph.EXPECT().SentPacket(gomock.Any())
|
||||||
sph.EXPECT().TimeUntilSend().Return(time.Now().Add(time.Hour))
|
sph.EXPECT().TimeUntilSend().Return(time.Now().Add(time.Hour))
|
||||||
sph.EXPECT().SendMode().Return(ackhandler.SendPacingLimited)
|
sph.EXPECT().SendMode().Return(ackhandler.SendPacingLimited)
|
||||||
packer.EXPECT().PackAckOnlyPacket(gomock.Any(), conn.version).Return(shortHeaderPacket{Packet: &ackhandler.Packet{PacketNumber: 123}}, getPacketBuffer(), nil)
|
packer.EXPECT().PackAckOnlyPacket(gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{Packet: &ackhandler.Packet{PacketNumber: 123}}, getPacketBuffer(), nil)
|
||||||
|
|
||||||
sender.EXPECT().WouldBlock().AnyTimes()
|
sender.EXPECT().WouldBlock().AnyTimes()
|
||||||
sender.EXPECT().Send(gomock.Any(), gomock.Any())
|
sender.EXPECT().Send(gomock.Any(), gomock.Any())
|
||||||
|
@ -1593,7 +1593,7 @@ var _ = Describe("Connection", func() {
|
||||||
sph.EXPECT().SentPacket(gomock.Any())
|
sph.EXPECT().SentPacket(gomock.Any())
|
||||||
sph.EXPECT().SendMode().Return(ackhandler.SendAny).AnyTimes()
|
sph.EXPECT().SendMode().Return(ackhandler.SendAny).AnyTimes()
|
||||||
expectAppendPacket(packer, shortHeaderPacket{Packet: &ackhandler.Packet{PacketNumber: 1000}}, []byte("packet1000"))
|
expectAppendPacket(packer, shortHeaderPacket{Packet: &ackhandler.Packet{PacketNumber: 1000}}, []byte("packet1000"))
|
||||||
packer.EXPECT().AppendPacket(gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, errNothingToPack)
|
packer.EXPECT().AppendPacket(gomock.Any(), gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, errNothingToPack)
|
||||||
sender.EXPECT().Send(gomock.Any(), gomock.Any()).DoAndReturn(func(*packetBuffer, protocol.ByteCount) { close(written) })
|
sender.EXPECT().Send(gomock.Any(), gomock.Any()).DoAndReturn(func(*packetBuffer, protocol.ByteCount) { close(written) })
|
||||||
available <- struct{}{}
|
available <- struct{}{}
|
||||||
Eventually(written).Should(BeClosed())
|
Eventually(written).Should(BeClosed())
|
||||||
|
@ -1616,7 +1616,7 @@ var _ = Describe("Connection", func() {
|
||||||
})
|
})
|
||||||
sph.EXPECT().SendMode().Return(ackhandler.SendAny).AnyTimes()
|
sph.EXPECT().SendMode().Return(ackhandler.SendAny).AnyTimes()
|
||||||
expectAppendPacket(packer, shortHeaderPacket{Packet: &ackhandler.Packet{PacketNumber: 10}}, []byte("packet10"))
|
expectAppendPacket(packer, shortHeaderPacket{Packet: &ackhandler.Packet{PacketNumber: 10}}, []byte("packet10"))
|
||||||
packer.EXPECT().AppendPacket(gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, errNothingToPack)
|
packer.EXPECT().AppendPacket(gomock.Any(), gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, errNothingToPack)
|
||||||
sender.EXPECT().Send(gomock.Any(), gomock.Any()).DoAndReturn(func(*packetBuffer, protocol.ByteCount) { close(written) })
|
sender.EXPECT().Send(gomock.Any(), gomock.Any()).DoAndReturn(func(*packetBuffer, protocol.ByteCount) { close(written) })
|
||||||
|
|
||||||
conn.scheduleSending()
|
conn.scheduleSending()
|
||||||
|
@ -1649,7 +1649,7 @@ var _ = Describe("Connection", func() {
|
||||||
sph.EXPECT().SendMode().Return(ackhandler.SendAny).AnyTimes()
|
sph.EXPECT().SendMode().Return(ackhandler.SendAny).AnyTimes()
|
||||||
sender.EXPECT().WouldBlock().AnyTimes()
|
sender.EXPECT().WouldBlock().AnyTimes()
|
||||||
expectAppendPacket(packer, shortHeaderPacket{Packet: &ackhandler.Packet{PacketNumber: 1001}}, []byte("packet1001"))
|
expectAppendPacket(packer, shortHeaderPacket{Packet: &ackhandler.Packet{PacketNumber: 1001}}, []byte("packet1001"))
|
||||||
packer.EXPECT().AppendPacket(gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, errNothingToPack)
|
packer.EXPECT().AppendPacket(gomock.Any(), gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, errNothingToPack)
|
||||||
sender.EXPECT().Send(gomock.Any(), gomock.Any()).DoAndReturn(func(*packetBuffer, protocol.ByteCount) { written <- struct{}{} })
|
sender.EXPECT().Send(gomock.Any(), gomock.Any()).DoAndReturn(func(*packetBuffer, protocol.ByteCount) { written <- struct{}{} })
|
||||||
available <- struct{}{}
|
available <- struct{}{}
|
||||||
Eventually(written).Should(Receive())
|
Eventually(written).Should(Receive())
|
||||||
|
@ -1662,7 +1662,7 @@ var _ = Describe("Connection", func() {
|
||||||
It("doesn't set a pacing timer when there is no data to send", func() {
|
It("doesn't set a pacing timer when there is no data to send", func() {
|
||||||
sph.EXPECT().SendMode().Return(ackhandler.SendAny).AnyTimes()
|
sph.EXPECT().SendMode().Return(ackhandler.SendAny).AnyTimes()
|
||||||
sender.EXPECT().WouldBlock().AnyTimes()
|
sender.EXPECT().WouldBlock().AnyTimes()
|
||||||
packer.EXPECT().AppendPacket(gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, errNothingToPack)
|
packer.EXPECT().AppendPacket(gomock.Any(), gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, errNothingToPack)
|
||||||
// don't EXPECT any calls to mconn.Write()
|
// don't EXPECT any calls to mconn.Write()
|
||||||
go func() {
|
go func() {
|
||||||
defer GinkgoRecover()
|
defer GinkgoRecover()
|
||||||
|
@ -1713,7 +1713,7 @@ var _ = Describe("Connection", func() {
|
||||||
// make the go routine return
|
// make the go routine return
|
||||||
expectReplaceWithClosed()
|
expectReplaceWithClosed()
|
||||||
streamManager.EXPECT().CloseWithError(gomock.Any())
|
streamManager.EXPECT().CloseWithError(gomock.Any())
|
||||||
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
||||||
sender.EXPECT().Close()
|
sender.EXPECT().Close()
|
||||||
|
@ -1732,7 +1732,7 @@ var _ = Describe("Connection", func() {
|
||||||
sph.EXPECT().SentPacket(gomock.Any())
|
sph.EXPECT().SentPacket(gomock.Any())
|
||||||
conn.sentPacketHandler = sph
|
conn.sentPacketHandler = sph
|
||||||
expectAppendPacket(packer, shortHeaderPacket{Packet: &ackhandler.Packet{PacketNumber: 1}}, []byte("packet1"))
|
expectAppendPacket(packer, shortHeaderPacket{Packet: &ackhandler.Packet{PacketNumber: 1}}, []byte("packet1"))
|
||||||
packer.EXPECT().AppendPacket(gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, errNothingToPack)
|
packer.EXPECT().AppendPacket(gomock.Any(), gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, errNothingToPack)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer GinkgoRecover()
|
defer GinkgoRecover()
|
||||||
|
@ -1751,7 +1751,7 @@ var _ = Describe("Connection", func() {
|
||||||
|
|
||||||
It("sets the timer to the ack timer", func() {
|
It("sets the timer to the ack timer", func() {
|
||||||
expectAppendPacket(packer, shortHeaderPacket{Packet: &ackhandler.Packet{PacketNumber: 1234}}, []byte("packet1234"))
|
expectAppendPacket(packer, shortHeaderPacket{Packet: &ackhandler.Packet{PacketNumber: 1234}}, []byte("packet1234"))
|
||||||
packer.EXPECT().AppendPacket(gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, errNothingToPack)
|
packer.EXPECT().AppendPacket(gomock.Any(), gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, errNothingToPack)
|
||||||
sph := mockackhandler.NewMockSentPacketHandler(mockCtrl)
|
sph := mockackhandler.NewMockSentPacketHandler(mockCtrl)
|
||||||
sph.EXPECT().GetLossDetectionTimeout().AnyTimes()
|
sph.EXPECT().GetLossDetectionTimeout().AnyTimes()
|
||||||
sph.EXPECT().SendMode().Return(ackhandler.SendAny).AnyTimes()
|
sph.EXPECT().SendMode().Return(ackhandler.SendAny).AnyTimes()
|
||||||
|
@ -1784,7 +1784,7 @@ var _ = Describe("Connection", func() {
|
||||||
conn.sentPacketHandler = sph
|
conn.sentPacketHandler = sph
|
||||||
buffer := getPacketBuffer()
|
buffer := getPacketBuffer()
|
||||||
buffer.Data = append(buffer.Data, []byte("foobar")...)
|
buffer.Data = append(buffer.Data, []byte("foobar")...)
|
||||||
packer.EXPECT().PackCoalescedPacket(false, gomock.Any(), conn.version).Return(&coalescedPacket{
|
packer.EXPECT().PackCoalescedPacket(false, gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{
|
||||||
buffer: buffer,
|
buffer: buffer,
|
||||||
longHdrPackets: []*longHeaderPacket{
|
longHdrPackets: []*longHeaderPacket{
|
||||||
{
|
{
|
||||||
|
@ -1803,7 +1803,7 @@ var _ = Describe("Connection", func() {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, nil)
|
}, nil)
|
||||||
packer.EXPECT().PackCoalescedPacket(false, gomock.Any(), conn.version).AnyTimes()
|
packer.EXPECT().PackCoalescedPacket(false, gomock.Any(), gomock.Any(), conn.version).AnyTimes()
|
||||||
|
|
||||||
sph.EXPECT().GetLossDetectionTimeout().AnyTimes()
|
sph.EXPECT().GetLossDetectionTimeout().AnyTimes()
|
||||||
sph.EXPECT().SendMode().Return(ackhandler.SendAny).AnyTimes()
|
sph.EXPECT().SendMode().Return(ackhandler.SendAny).AnyTimes()
|
||||||
|
@ -1844,7 +1844,7 @@ var _ = Describe("Connection", func() {
|
||||||
// make sure the go routine returns
|
// make sure the go routine returns
|
||||||
streamManager.EXPECT().CloseWithError(gomock.Any())
|
streamManager.EXPECT().CloseWithError(gomock.Any())
|
||||||
expectReplaceWithClosed()
|
expectReplaceWithClosed()
|
||||||
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
||||||
tracer.EXPECT().ClosedConnection(gomock.Any())
|
tracer.EXPECT().ClosedConnection(gomock.Any())
|
||||||
|
@ -1854,7 +1854,7 @@ var _ = Describe("Connection", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
It("cancels the HandshakeComplete context when the handshake completes", func() {
|
It("cancels the HandshakeComplete context when the handshake completes", func() {
|
||||||
packer.EXPECT().PackCoalescedPacket(false, gomock.Any(), conn.version).AnyTimes()
|
packer.EXPECT().PackCoalescedPacket(false, gomock.Any(), gomock.Any(), conn.version).AnyTimes()
|
||||||
finishHandshake := make(chan struct{})
|
finishHandshake := make(chan struct{})
|
||||||
sph := mockackhandler.NewMockSentPacketHandler(mockCtrl)
|
sph := mockackhandler.NewMockSentPacketHandler(mockCtrl)
|
||||||
conn.sentPacketHandler = sph
|
conn.sentPacketHandler = sph
|
||||||
|
@ -1879,7 +1879,7 @@ var _ = Describe("Connection", func() {
|
||||||
// make sure the go routine returns
|
// make sure the go routine returns
|
||||||
streamManager.EXPECT().CloseWithError(gomock.Any())
|
streamManager.EXPECT().CloseWithError(gomock.Any())
|
||||||
expectReplaceWithClosed()
|
expectReplaceWithClosed()
|
||||||
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
||||||
tracer.EXPECT().ClosedConnection(gomock.Any())
|
tracer.EXPECT().ClosedConnection(gomock.Any())
|
||||||
|
@ -1890,7 +1890,7 @@ var _ = Describe("Connection", func() {
|
||||||
|
|
||||||
It("sends a connection ticket when the handshake completes", func() {
|
It("sends a connection ticket when the handshake completes", func() {
|
||||||
const size = protocol.MaxPostHandshakeCryptoFrameSize * 3 / 2
|
const size = protocol.MaxPostHandshakeCryptoFrameSize * 3 / 2
|
||||||
packer.EXPECT().PackCoalescedPacket(false, gomock.Any(), conn.version).AnyTimes()
|
packer.EXPECT().PackCoalescedPacket(false, gomock.Any(), gomock.Any(), conn.version).AnyTimes()
|
||||||
finishHandshake := make(chan struct{})
|
finishHandshake := make(chan struct{})
|
||||||
connRunner.EXPECT().Retire(clientDestConnID)
|
connRunner.EXPECT().Retire(clientDestConnID)
|
||||||
go func() {
|
go func() {
|
||||||
|
@ -1924,7 +1924,7 @@ var _ = Describe("Connection", func() {
|
||||||
// make sure the go routine returns
|
// make sure the go routine returns
|
||||||
streamManager.EXPECT().CloseWithError(gomock.Any())
|
streamManager.EXPECT().CloseWithError(gomock.Any())
|
||||||
expectReplaceWithClosed()
|
expectReplaceWithClosed()
|
||||||
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
||||||
tracer.EXPECT().ClosedConnection(gomock.Any())
|
tracer.EXPECT().ClosedConnection(gomock.Any())
|
||||||
|
@ -1934,10 +1934,10 @@ var _ = Describe("Connection", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
It("doesn't cancel the HandshakeComplete context when the handshake fails", func() {
|
It("doesn't cancel the HandshakeComplete context when the handshake fails", func() {
|
||||||
packer.EXPECT().PackCoalescedPacket(false, gomock.Any(), conn.version).AnyTimes()
|
packer.EXPECT().PackCoalescedPacket(false, gomock.Any(), gomock.Any(), conn.version).AnyTimes()
|
||||||
streamManager.EXPECT().CloseWithError(gomock.Any())
|
streamManager.EXPECT().CloseWithError(gomock.Any())
|
||||||
expectReplaceWithClosed()
|
expectReplaceWithClosed()
|
||||||
packer.EXPECT().PackConnectionClose(gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
packer.EXPECT().PackConnectionClose(gomock.Any(), gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
tracer.EXPECT().ClosedConnection(gomock.Any())
|
tracer.EXPECT().ClosedConnection(gomock.Any())
|
||||||
tracer.EXPECT().Close()
|
tracer.EXPECT().Close()
|
||||||
|
@ -1966,14 +1966,14 @@ var _ = Describe("Connection", func() {
|
||||||
conn.sentPacketHandler = sph
|
conn.sentPacketHandler = sph
|
||||||
done := make(chan struct{})
|
done := make(chan struct{})
|
||||||
connRunner.EXPECT().Retire(clientDestConnID)
|
connRunner.EXPECT().Retire(clientDestConnID)
|
||||||
packer.EXPECT().AppendPacket(gomock.Any(), gomock.Any(), conn.version).DoAndReturn(func(_ *packetBuffer, _ protocol.ByteCount, v protocol.VersionNumber) (shortHeaderPacket, error) {
|
packer.EXPECT().AppendPacket(gomock.Any(), gomock.Any(), gomock.Any(), conn.version).DoAndReturn(func(_ *packetBuffer, _ protocol.ByteCount, _ time.Time, v protocol.VersionNumber) (shortHeaderPacket, error) {
|
||||||
frames, _ := conn.framer.AppendControlFrames(nil, protocol.MaxByteCount, v)
|
frames, _ := conn.framer.AppendControlFrames(nil, protocol.MaxByteCount, v)
|
||||||
Expect(frames).ToNot(BeEmpty())
|
Expect(frames).ToNot(BeEmpty())
|
||||||
Expect(frames[0].Frame).To(BeEquivalentTo(&wire.HandshakeDoneFrame{}))
|
Expect(frames[0].Frame).To(BeEquivalentTo(&wire.HandshakeDoneFrame{}))
|
||||||
defer close(done)
|
defer close(done)
|
||||||
return shortHeaderPacket{Packet: &ackhandler.Packet{}}, nil
|
return shortHeaderPacket{Packet: &ackhandler.Packet{}}, nil
|
||||||
})
|
})
|
||||||
packer.EXPECT().AppendPacket(gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, errNothingToPack).AnyTimes()
|
packer.EXPECT().AppendPacket(gomock.Any(), gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, errNothingToPack).AnyTimes()
|
||||||
go func() {
|
go func() {
|
||||||
defer GinkgoRecover()
|
defer GinkgoRecover()
|
||||||
cryptoSetup.EXPECT().RunHandshake()
|
cryptoSetup.EXPECT().RunHandshake()
|
||||||
|
@ -1987,7 +1987,7 @@ var _ = Describe("Connection", func() {
|
||||||
// make sure the go routine returns
|
// make sure the go routine returns
|
||||||
streamManager.EXPECT().CloseWithError(gomock.Any())
|
streamManager.EXPECT().CloseWithError(gomock.Any())
|
||||||
expectReplaceWithClosed()
|
expectReplaceWithClosed()
|
||||||
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
tracer.EXPECT().ClosedConnection(gomock.Any())
|
tracer.EXPECT().ClosedConnection(gomock.Any())
|
||||||
tracer.EXPECT().Close()
|
tracer.EXPECT().Close()
|
||||||
|
@ -2005,7 +2005,7 @@ var _ = Describe("Connection", func() {
|
||||||
}()
|
}()
|
||||||
streamManager.EXPECT().CloseWithError(gomock.Any())
|
streamManager.EXPECT().CloseWithError(gomock.Any())
|
||||||
expectReplaceWithClosed()
|
expectReplaceWithClosed()
|
||||||
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
||||||
tracer.EXPECT().ClosedConnection(gomock.Any())
|
tracer.EXPECT().ClosedConnection(gomock.Any())
|
||||||
|
@ -2029,7 +2029,7 @@ var _ = Describe("Connection", func() {
|
||||||
}()
|
}()
|
||||||
streamManager.EXPECT().CloseWithError(gomock.Any())
|
streamManager.EXPECT().CloseWithError(gomock.Any())
|
||||||
expectReplaceWithClosed()
|
expectReplaceWithClosed()
|
||||||
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
||||||
tracer.EXPECT().ClosedConnection(gomock.Any())
|
tracer.EXPECT().ClosedConnection(gomock.Any())
|
||||||
|
@ -2050,7 +2050,7 @@ var _ = Describe("Connection", func() {
|
||||||
InitialSourceConnectionID: destConnID,
|
InitialSourceConnectionID: destConnID,
|
||||||
}
|
}
|
||||||
streamManager.EXPECT().UpdateLimits(params)
|
streamManager.EXPECT().UpdateLimits(params)
|
||||||
packer.EXPECT().PackCoalescedPacket(false, gomock.Any(), conn.version).MaxTimes(3)
|
packer.EXPECT().PackCoalescedPacket(false, gomock.Any(), gomock.Any(), conn.version).MaxTimes(3)
|
||||||
Expect(conn.earlyConnReady()).ToNot(BeClosed())
|
Expect(conn.earlyConnReady()).ToNot(BeClosed())
|
||||||
tracer.EXPECT().ReceivedTransportParameters(params)
|
tracer.EXPECT().ReceivedTransportParameters(params)
|
||||||
conn.handleTransportParameters(params)
|
conn.handleTransportParameters(params)
|
||||||
|
@ -2086,7 +2086,7 @@ var _ = Describe("Connection", func() {
|
||||||
// make the go routine return
|
// make the go routine return
|
||||||
expectReplaceWithClosed()
|
expectReplaceWithClosed()
|
||||||
streamManager.EXPECT().CloseWithError(gomock.Any())
|
streamManager.EXPECT().CloseWithError(gomock.Any())
|
||||||
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
||||||
tracer.EXPECT().ClosedConnection(gomock.Any())
|
tracer.EXPECT().ClosedConnection(gomock.Any())
|
||||||
|
@ -2099,7 +2099,7 @@ var _ = Describe("Connection", func() {
|
||||||
setRemoteIdleTimeout(5 * time.Second)
|
setRemoteIdleTimeout(5 * time.Second)
|
||||||
conn.lastPacketReceivedTime = time.Now().Add(-5 * time.Second / 2)
|
conn.lastPacketReceivedTime = time.Now().Add(-5 * time.Second / 2)
|
||||||
sent := make(chan struct{})
|
sent := make(chan struct{})
|
||||||
packer.EXPECT().PackCoalescedPacket(false, gomock.Any(), conn.version).Do(func(bool, protocol.ByteCount, protocol.VersionNumber) (*coalescedPacket, error) {
|
packer.EXPECT().PackCoalescedPacket(false, gomock.Any(), gomock.Any(), conn.version).Do(func(bool, protocol.ByteCount, time.Time, protocol.VersionNumber) (*coalescedPacket, error) {
|
||||||
close(sent)
|
close(sent)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
})
|
})
|
||||||
|
@ -2112,7 +2112,7 @@ var _ = Describe("Connection", func() {
|
||||||
setRemoteIdleTimeout(time.Hour)
|
setRemoteIdleTimeout(time.Hour)
|
||||||
conn.lastPacketReceivedTime = time.Now().Add(-protocol.MaxKeepAliveInterval).Add(-time.Millisecond)
|
conn.lastPacketReceivedTime = time.Now().Add(-protocol.MaxKeepAliveInterval).Add(-time.Millisecond)
|
||||||
sent := make(chan struct{})
|
sent := make(chan struct{})
|
||||||
packer.EXPECT().PackCoalescedPacket(false, gomock.Any(), conn.version).Do(func(bool, protocol.ByteCount, protocol.VersionNumber) (*coalescedPacket, error) {
|
packer.EXPECT().PackCoalescedPacket(false, gomock.Any(), gomock.Any(), conn.version).Do(func(bool, protocol.ByteCount, time.Time, protocol.VersionNumber) (*coalescedPacket, error) {
|
||||||
close(sent)
|
close(sent)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
})
|
})
|
||||||
|
@ -2200,7 +2200,7 @@ var _ = Describe("Connection", func() {
|
||||||
conn.config.HandshakeIdleTimeout = 9999 * time.Second
|
conn.config.HandshakeIdleTimeout = 9999 * time.Second
|
||||||
conn.config.MaxIdleTimeout = 9999 * time.Second
|
conn.config.MaxIdleTimeout = 9999 * time.Second
|
||||||
conn.lastPacketReceivedTime = time.Now().Add(-time.Minute)
|
conn.lastPacketReceivedTime = time.Now().Add(-time.Minute)
|
||||||
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), conn.version).DoAndReturn(func(e *qerr.ApplicationError, _ protocol.ByteCount, _ protocol.VersionNumber) (*coalescedPacket, error) {
|
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), gomock.Any(), conn.version).DoAndReturn(func(e *qerr.ApplicationError, _ protocol.ByteCount, _ time.Time, _ protocol.VersionNumber) (*coalescedPacket, error) {
|
||||||
Expect(e.ErrorCode).To(BeZero())
|
Expect(e.ErrorCode).To(BeZero())
|
||||||
return &coalescedPacket{buffer: getPacketBuffer()}, nil
|
return &coalescedPacket{buffer: getPacketBuffer()}, nil
|
||||||
})
|
})
|
||||||
|
@ -2231,7 +2231,7 @@ var _ = Describe("Connection", func() {
|
||||||
|
|
||||||
It("closes the connection due to the idle timeout before handshake", func() {
|
It("closes the connection due to the idle timeout before handshake", func() {
|
||||||
conn.config.HandshakeIdleTimeout = 0
|
conn.config.HandshakeIdleTimeout = 0
|
||||||
packer.EXPECT().PackCoalescedPacket(false, gomock.Any(), conn.version).AnyTimes()
|
packer.EXPECT().PackCoalescedPacket(false, gomock.Any(), gomock.Any(), conn.version).AnyTimes()
|
||||||
connRunner.EXPECT().Remove(gomock.Any()).AnyTimes()
|
connRunner.EXPECT().Remove(gomock.Any()).AnyTimes()
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
gomock.InOrder(
|
gomock.InOrder(
|
||||||
|
@ -2257,7 +2257,7 @@ var _ = Describe("Connection", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
It("closes the connection due to the idle timeout after handshake", func() {
|
It("closes the connection due to the idle timeout after handshake", func() {
|
||||||
packer.EXPECT().PackCoalescedPacket(false, gomock.Any(), conn.version).AnyTimes()
|
packer.EXPECT().PackCoalescedPacket(false, gomock.Any(), gomock.Any(), conn.version).AnyTimes()
|
||||||
gomock.InOrder(
|
gomock.InOrder(
|
||||||
connRunner.EXPECT().Retire(clientDestConnID),
|
connRunner.EXPECT().Retire(clientDestConnID),
|
||||||
connRunner.EXPECT().Remove(gomock.Any()),
|
connRunner.EXPECT().Remove(gomock.Any()),
|
||||||
|
@ -2298,7 +2298,7 @@ var _ = Describe("Connection", func() {
|
||||||
}()
|
}()
|
||||||
Consistently(conn.Context().Done()).ShouldNot(BeClosed())
|
Consistently(conn.Context().Done()).ShouldNot(BeClosed())
|
||||||
// make the go routine return
|
// make the go routine return
|
||||||
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
||||||
expectReplaceWithClosed()
|
expectReplaceWithClosed()
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
||||||
|
@ -2485,7 +2485,7 @@ var _ = Describe("Client Connection", func() {
|
||||||
tracer.EXPECT().ReceivedLongHeaderPacket(gomock.Any(), p.Size(), []logging.Frame{})
|
tracer.EXPECT().ReceivedLongHeaderPacket(gomock.Any(), p.Size(), []logging.Frame{})
|
||||||
Expect(conn.handlePacketImpl(p)).To(BeTrue())
|
Expect(conn.handlePacketImpl(p)).To(BeTrue())
|
||||||
// make sure the go routine returns
|
// make sure the go routine returns
|
||||||
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
||||||
expectReplaceWithClosed()
|
expectReplaceWithClosed()
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
||||||
|
@ -2744,9 +2744,9 @@ var _ = Describe("Client Connection", func() {
|
||||||
if !closed {
|
if !closed {
|
||||||
connRunner.EXPECT().ReplaceWithClosed(gomock.Any(), gomock.Any(), gomock.Any())
|
connRunner.EXPECT().ReplaceWithClosed(gomock.Any(), gomock.Any(), gomock.Any())
|
||||||
if applicationClose {
|
if applicationClose {
|
||||||
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil).MaxTimes(1)
|
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil).MaxTimes(1)
|
||||||
} else {
|
} else {
|
||||||
packer.EXPECT().PackConnectionClose(gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil).MaxTimes(1)
|
packer.EXPECT().PackConnectionClose(gomock.Any(), gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil).MaxTimes(1)
|
||||||
}
|
}
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
||||||
|
@ -2775,7 +2775,7 @@ var _ = Describe("Client Connection", func() {
|
||||||
StatelessResetToken: protocol.StatelessResetToken{16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1},
|
StatelessResetToken: protocol.StatelessResetToken{16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
packer.EXPECT().PackCoalescedPacket(false, gomock.Any(), conn.version).MaxTimes(1)
|
packer.EXPECT().PackCoalescedPacket(false, gomock.Any(), gomock.Any(), conn.version).MaxTimes(1)
|
||||||
tracer.EXPECT().ReceivedTransportParameters(params)
|
tracer.EXPECT().ReceivedTransportParameters(params)
|
||||||
conn.handleTransportParameters(params)
|
conn.handleTransportParameters(params)
|
||||||
conn.handleHandshakeComplete()
|
conn.handleHandshakeComplete()
|
||||||
|
|
|
@ -38,39 +38,39 @@ func (m *MockPacker) EXPECT() *MockPackerMockRecorder {
|
||||||
}
|
}
|
||||||
|
|
||||||
// AppendPacket mocks base method.
|
// AppendPacket mocks base method.
|
||||||
func (m *MockPacker) AppendPacket(arg0 *packetBuffer, arg1 protocol.ByteCount, arg2 protocol.VersionNumber) (shortHeaderPacket, error) {
|
func (m *MockPacker) AppendPacket(arg0 *packetBuffer, arg1 protocol.ByteCount, arg2 time.Time, arg3 protocol.VersionNumber) (shortHeaderPacket, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "AppendPacket", arg0, arg1, arg2)
|
ret := m.ctrl.Call(m, "AppendPacket", arg0, arg1, arg2, arg3)
|
||||||
ret0, _ := ret[0].(shortHeaderPacket)
|
ret0, _ := ret[0].(shortHeaderPacket)
|
||||||
ret1, _ := ret[1].(error)
|
ret1, _ := ret[1].(error)
|
||||||
return ret0, ret1
|
return ret0, ret1
|
||||||
}
|
}
|
||||||
|
|
||||||
// AppendPacket indicates an expected call of AppendPacket.
|
// AppendPacket indicates an expected call of AppendPacket.
|
||||||
func (mr *MockPackerMockRecorder) AppendPacket(arg0, arg1, arg2 interface{}) *gomock.Call {
|
func (mr *MockPackerMockRecorder) AppendPacket(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AppendPacket", reflect.TypeOf((*MockPacker)(nil).AppendPacket), arg0, arg1, arg2)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AppendPacket", reflect.TypeOf((*MockPacker)(nil).AppendPacket), arg0, arg1, arg2, arg3)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MaybePackProbePacket mocks base method.
|
// MaybePackProbePacket mocks base method.
|
||||||
func (m *MockPacker) MaybePackProbePacket(arg0 protocol.EncryptionLevel, arg1 protocol.ByteCount, arg2 protocol.VersionNumber) (*coalescedPacket, error) {
|
func (m *MockPacker) MaybePackProbePacket(arg0 protocol.EncryptionLevel, arg1 protocol.ByteCount, arg2 time.Time, arg3 protocol.VersionNumber) (*coalescedPacket, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "MaybePackProbePacket", arg0, arg1, arg2)
|
ret := m.ctrl.Call(m, "MaybePackProbePacket", arg0, arg1, arg2, arg3)
|
||||||
ret0, _ := ret[0].(*coalescedPacket)
|
ret0, _ := ret[0].(*coalescedPacket)
|
||||||
ret1, _ := ret[1].(error)
|
ret1, _ := ret[1].(error)
|
||||||
return ret0, ret1
|
return ret0, ret1
|
||||||
}
|
}
|
||||||
|
|
||||||
// MaybePackProbePacket indicates an expected call of MaybePackProbePacket.
|
// MaybePackProbePacket indicates an expected call of MaybePackProbePacket.
|
||||||
func (mr *MockPackerMockRecorder) MaybePackProbePacket(arg0, arg1, arg2 interface{}) *gomock.Call {
|
func (mr *MockPackerMockRecorder) MaybePackProbePacket(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MaybePackProbePacket", reflect.TypeOf((*MockPacker)(nil).MaybePackProbePacket), arg0, arg1, arg2)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MaybePackProbePacket", reflect.TypeOf((*MockPacker)(nil).MaybePackProbePacket), arg0, arg1, arg2, arg3)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PackAckOnlyPacket mocks base method.
|
// PackAckOnlyPacket mocks base method.
|
||||||
func (m *MockPacker) PackAckOnlyPacket(arg0 protocol.ByteCount, arg1 protocol.VersionNumber) (shortHeaderPacket, *packetBuffer, error) {
|
func (m *MockPacker) PackAckOnlyPacket(arg0 protocol.ByteCount, arg1 time.Time, arg2 protocol.VersionNumber) (shortHeaderPacket, *packetBuffer, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "PackAckOnlyPacket", arg0, arg1)
|
ret := m.ctrl.Call(m, "PackAckOnlyPacket", arg0, arg1, arg2)
|
||||||
ret0, _ := ret[0].(shortHeaderPacket)
|
ret0, _ := ret[0].(shortHeaderPacket)
|
||||||
ret1, _ := ret[1].(*packetBuffer)
|
ret1, _ := ret[1].(*packetBuffer)
|
||||||
ret2, _ := ret[2].(error)
|
ret2, _ := ret[2].(error)
|
||||||
|
@ -78,54 +78,54 @@ func (m *MockPacker) PackAckOnlyPacket(arg0 protocol.ByteCount, arg1 protocol.Ve
|
||||||
}
|
}
|
||||||
|
|
||||||
// PackAckOnlyPacket indicates an expected call of PackAckOnlyPacket.
|
// PackAckOnlyPacket indicates an expected call of PackAckOnlyPacket.
|
||||||
func (mr *MockPackerMockRecorder) PackAckOnlyPacket(arg0, arg1 interface{}) *gomock.Call {
|
func (mr *MockPackerMockRecorder) PackAckOnlyPacket(arg0, arg1, arg2 interface{}) *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PackAckOnlyPacket", reflect.TypeOf((*MockPacker)(nil).PackAckOnlyPacket), arg0, arg1)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PackAckOnlyPacket", reflect.TypeOf((*MockPacker)(nil).PackAckOnlyPacket), arg0, arg1, arg2)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PackApplicationClose mocks base method.
|
// PackApplicationClose mocks base method.
|
||||||
func (m *MockPacker) PackApplicationClose(arg0 *qerr.ApplicationError, arg1 protocol.ByteCount, arg2 protocol.VersionNumber) (*coalescedPacket, error) {
|
func (m *MockPacker) PackApplicationClose(arg0 *qerr.ApplicationError, arg1 protocol.ByteCount, arg2 time.Time, arg3 protocol.VersionNumber) (*coalescedPacket, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "PackApplicationClose", arg0, arg1, arg2)
|
ret := m.ctrl.Call(m, "PackApplicationClose", arg0, arg1, arg2, arg3)
|
||||||
ret0, _ := ret[0].(*coalescedPacket)
|
ret0, _ := ret[0].(*coalescedPacket)
|
||||||
ret1, _ := ret[1].(error)
|
ret1, _ := ret[1].(error)
|
||||||
return ret0, ret1
|
return ret0, ret1
|
||||||
}
|
}
|
||||||
|
|
||||||
// PackApplicationClose indicates an expected call of PackApplicationClose.
|
// PackApplicationClose indicates an expected call of PackApplicationClose.
|
||||||
func (mr *MockPackerMockRecorder) PackApplicationClose(arg0, arg1, arg2 interface{}) *gomock.Call {
|
func (mr *MockPackerMockRecorder) PackApplicationClose(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PackApplicationClose", reflect.TypeOf((*MockPacker)(nil).PackApplicationClose), arg0, arg1, arg2)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PackApplicationClose", reflect.TypeOf((*MockPacker)(nil).PackApplicationClose), arg0, arg1, arg2, arg3)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PackCoalescedPacket mocks base method.
|
// PackCoalescedPacket mocks base method.
|
||||||
func (m *MockPacker) PackCoalescedPacket(arg0 bool, arg1 protocol.ByteCount, arg2 protocol.VersionNumber) (*coalescedPacket, error) {
|
func (m *MockPacker) PackCoalescedPacket(arg0 bool, arg1 protocol.ByteCount, arg2 time.Time, arg3 protocol.VersionNumber) (*coalescedPacket, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "PackCoalescedPacket", arg0, arg1, arg2)
|
ret := m.ctrl.Call(m, "PackCoalescedPacket", arg0, arg1, arg2, arg3)
|
||||||
ret0, _ := ret[0].(*coalescedPacket)
|
ret0, _ := ret[0].(*coalescedPacket)
|
||||||
ret1, _ := ret[1].(error)
|
ret1, _ := ret[1].(error)
|
||||||
return ret0, ret1
|
return ret0, ret1
|
||||||
}
|
}
|
||||||
|
|
||||||
// PackCoalescedPacket indicates an expected call of PackCoalescedPacket.
|
// PackCoalescedPacket indicates an expected call of PackCoalescedPacket.
|
||||||
func (mr *MockPackerMockRecorder) PackCoalescedPacket(arg0, arg1, arg2 interface{}) *gomock.Call {
|
func (mr *MockPackerMockRecorder) PackCoalescedPacket(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PackCoalescedPacket", reflect.TypeOf((*MockPacker)(nil).PackCoalescedPacket), arg0, arg1, arg2)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PackCoalescedPacket", reflect.TypeOf((*MockPacker)(nil).PackCoalescedPacket), arg0, arg1, arg2, arg3)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PackConnectionClose mocks base method.
|
// PackConnectionClose mocks base method.
|
||||||
func (m *MockPacker) PackConnectionClose(arg0 *qerr.TransportError, arg1 protocol.ByteCount, arg2 protocol.VersionNumber) (*coalescedPacket, error) {
|
func (m *MockPacker) PackConnectionClose(arg0 *qerr.TransportError, arg1 protocol.ByteCount, arg2 time.Time, arg3 protocol.VersionNumber) (*coalescedPacket, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "PackConnectionClose", arg0, arg1, arg2)
|
ret := m.ctrl.Call(m, "PackConnectionClose", arg0, arg1, arg2, arg3)
|
||||||
ret0, _ := ret[0].(*coalescedPacket)
|
ret0, _ := ret[0].(*coalescedPacket)
|
||||||
ret1, _ := ret[1].(error)
|
ret1, _ := ret[1].(error)
|
||||||
return ret0, ret1
|
return ret0, ret1
|
||||||
}
|
}
|
||||||
|
|
||||||
// PackConnectionClose indicates an expected call of PackConnectionClose.
|
// PackConnectionClose indicates an expected call of PackConnectionClose.
|
||||||
func (mr *MockPackerMockRecorder) PackConnectionClose(arg0, arg1, arg2 interface{}) *gomock.Call {
|
func (mr *MockPackerMockRecorder) PackConnectionClose(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PackConnectionClose", reflect.TypeOf((*MockPacker)(nil).PackConnectionClose), arg0, arg1, arg2)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PackConnectionClose", reflect.TypeOf((*MockPacker)(nil).PackConnectionClose), arg0, arg1, arg2, arg3)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PackMTUProbePacket mocks base method.
|
// PackMTUProbePacket mocks base method.
|
||||||
|
|
|
@ -15,12 +15,12 @@ import (
|
||||||
var errNothingToPack = errors.New("nothing to pack")
|
var errNothingToPack = errors.New("nothing to pack")
|
||||||
|
|
||||||
type packer interface {
|
type packer interface {
|
||||||
PackCoalescedPacket(onlyAck bool, maxPacketSize protocol.ByteCount, v protocol.VersionNumber) (*coalescedPacket, error)
|
PackCoalescedPacket(onlyAck bool, maxPacketSize protocol.ByteCount, now time.Time, v protocol.VersionNumber) (*coalescedPacket, error)
|
||||||
PackAckOnlyPacket(maxPacketSize protocol.ByteCount, v protocol.VersionNumber) (shortHeaderPacket, *packetBuffer, error)
|
PackAckOnlyPacket(maxPacketSize protocol.ByteCount, now time.Time, v protocol.VersionNumber) (shortHeaderPacket, *packetBuffer, error)
|
||||||
AppendPacket(buf *packetBuffer, maxPacketSize protocol.ByteCount, v protocol.VersionNumber) (shortHeaderPacket, error)
|
AppendPacket(buf *packetBuffer, maxPacketSize protocol.ByteCount, now time.Time, v protocol.VersionNumber) (shortHeaderPacket, error)
|
||||||
MaybePackProbePacket(protocol.EncryptionLevel, protocol.ByteCount, protocol.VersionNumber) (*coalescedPacket, error)
|
MaybePackProbePacket(protocol.EncryptionLevel, protocol.ByteCount, time.Time, protocol.VersionNumber) (*coalescedPacket, error)
|
||||||
PackConnectionClose(*qerr.TransportError, protocol.ByteCount, protocol.VersionNumber) (*coalescedPacket, error)
|
PackConnectionClose(*qerr.TransportError, protocol.ByteCount, time.Time, protocol.VersionNumber) (*coalescedPacket, error)
|
||||||
PackApplicationClose(*qerr.ApplicationError, protocol.ByteCount, protocol.VersionNumber) (*coalescedPacket, error)
|
PackApplicationClose(*qerr.ApplicationError, protocol.ByteCount, time.Time, protocol.VersionNumber) (*coalescedPacket, error)
|
||||||
PackMTUProbePacket(ping ackhandler.Frame, size protocol.ByteCount, now time.Time, v protocol.VersionNumber) (shortHeaderPacket, *packetBuffer, error)
|
PackMTUProbePacket(ping ackhandler.Frame, size protocol.ByteCount, now time.Time, v protocol.VersionNumber) (shortHeaderPacket, *packetBuffer, error)
|
||||||
|
|
||||||
SetToken([]byte)
|
SetToken([]byte)
|
||||||
|
@ -187,18 +187,18 @@ func newPacketPacker(
|
||||||
}
|
}
|
||||||
|
|
||||||
// PackConnectionClose packs a packet that closes the connection with a transport error.
|
// PackConnectionClose packs a packet that closes the connection with a transport error.
|
||||||
func (p *packetPacker) PackConnectionClose(e *qerr.TransportError, maxPacketSize protocol.ByteCount, v protocol.VersionNumber) (*coalescedPacket, error) {
|
func (p *packetPacker) PackConnectionClose(e *qerr.TransportError, maxPacketSize protocol.ByteCount, now time.Time, v protocol.VersionNumber) (*coalescedPacket, error) {
|
||||||
var reason string
|
var reason string
|
||||||
// don't send details of crypto errors
|
// don't send details of crypto errors
|
||||||
if !e.ErrorCode.IsCryptoError() {
|
if !e.ErrorCode.IsCryptoError() {
|
||||||
reason = e.ErrorMessage
|
reason = e.ErrorMessage
|
||||||
}
|
}
|
||||||
return p.packConnectionClose(false, uint64(e.ErrorCode), e.FrameType, reason, maxPacketSize, v)
|
return p.packConnectionClose(false, uint64(e.ErrorCode), e.FrameType, reason, maxPacketSize, now, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PackApplicationClose packs a packet that closes the connection with an application error.
|
// PackApplicationClose packs a packet that closes the connection with an application error.
|
||||||
func (p *packetPacker) PackApplicationClose(e *qerr.ApplicationError, maxPacketSize protocol.ByteCount, v protocol.VersionNumber) (*coalescedPacket, error) {
|
func (p *packetPacker) PackApplicationClose(e *qerr.ApplicationError, maxPacketSize protocol.ByteCount, now time.Time, v protocol.VersionNumber) (*coalescedPacket, error) {
|
||||||
return p.packConnectionClose(true, uint64(e.ErrorCode), 0, e.ErrorMessage, maxPacketSize, v)
|
return p.packConnectionClose(true, uint64(e.ErrorCode), 0, e.ErrorMessage, maxPacketSize, now, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *packetPacker) packConnectionClose(
|
func (p *packetPacker) packConnectionClose(
|
||||||
|
@ -207,6 +207,7 @@ func (p *packetPacker) packConnectionClose(
|
||||||
frameType uint64,
|
frameType uint64,
|
||||||
reason string,
|
reason string,
|
||||||
maxPacketSize protocol.ByteCount,
|
maxPacketSize protocol.ByteCount,
|
||||||
|
now time.Time,
|
||||||
v protocol.VersionNumber,
|
v protocol.VersionNumber,
|
||||||
) (*coalescedPacket, error) {
|
) (*coalescedPacket, error) {
|
||||||
var sealers [4]sealer
|
var sealers [4]sealer
|
||||||
|
@ -291,7 +292,7 @@ func (p *packetPacker) packConnectionClose(
|
||||||
paddingLen = p.initialPaddingLen(payloads[i].frames, size, maxPacketSize)
|
paddingLen = p.initialPaddingLen(payloads[i].frames, size, maxPacketSize)
|
||||||
}
|
}
|
||||||
if encLevel == protocol.Encryption1RTT {
|
if encLevel == protocol.Encryption1RTT {
|
||||||
ap, ack, err := p.appendShortHeaderPacket(buffer, connID, oneRTTPacketNumber, oneRTTPacketNumberLen, keyPhase, payloads[i], paddingLen, maxPacketSize, sealers[i], false, v)
|
ap, ack, err := p.appendShortHeaderPacket(buffer, connID, oneRTTPacketNumber, oneRTTPacketNumberLen, keyPhase, payloads[i], paddingLen, maxPacketSize, sealers[i], false, now, v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -351,7 +352,7 @@ func (p *packetPacker) initialPaddingLen(frames []ackhandler.Frame, currentSize,
|
||||||
// PackCoalescedPacket packs a new packet.
|
// PackCoalescedPacket packs a new packet.
|
||||||
// It packs an Initial / Handshake if there is data to send in these packet number spaces.
|
// It packs an Initial / Handshake if there is data to send in these packet number spaces.
|
||||||
// It should only be called before the handshake is confirmed.
|
// It should only be called before the handshake is confirmed.
|
||||||
func (p *packetPacker) PackCoalescedPacket(onlyAck bool, maxPacketSize protocol.ByteCount, v protocol.VersionNumber) (*coalescedPacket, error) {
|
func (p *packetPacker) PackCoalescedPacket(onlyAck bool, maxPacketSize protocol.ByteCount, now time.Time, v protocol.VersionNumber) (*coalescedPacket, error) {
|
||||||
var (
|
var (
|
||||||
initialHdr, handshakeHdr, zeroRTTHdr *wire.ExtendedHeader
|
initialHdr, handshakeHdr, zeroRTTHdr *wire.ExtendedHeader
|
||||||
initialPayload, handshakePayload, zeroRTTPayload, oneRTTPayload payload
|
initialPayload, handshakePayload, zeroRTTPayload, oneRTTPayload payload
|
||||||
|
@ -454,7 +455,7 @@ func (p *packetPacker) PackCoalescedPacket(onlyAck bool, maxPacketSize protocol.
|
||||||
}
|
}
|
||||||
packet.longHdrPackets = append(packet.longHdrPackets, longHdrPacket)
|
packet.longHdrPackets = append(packet.longHdrPackets, longHdrPacket)
|
||||||
} else if oneRTTPayload.length > 0 {
|
} else if oneRTTPayload.length > 0 {
|
||||||
ap, ack, err := p.appendShortHeaderPacket(buffer, connID, oneRTTPacketNumber, oneRTTPacketNumberLen, kp, oneRTTPayload, 0, maxPacketSize, oneRTTSealer, false, v)
|
ap, ack, err := p.appendShortHeaderPacket(buffer, connID, oneRTTPacketNumber, oneRTTPacketNumberLen, kp, oneRTTPayload, 0, maxPacketSize, oneRTTSealer, false, now, v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -471,19 +472,19 @@ func (p *packetPacker) PackCoalescedPacket(onlyAck bool, maxPacketSize protocol.
|
||||||
|
|
||||||
// PackAckOnlyPacket packs a packet containing only an ACK in the application data packet number space.
|
// PackAckOnlyPacket packs a packet containing only an ACK in the application data packet number space.
|
||||||
// It should be called after the handshake is confirmed.
|
// It should be called after the handshake is confirmed.
|
||||||
func (p *packetPacker) PackAckOnlyPacket(maxPacketSize protocol.ByteCount, v protocol.VersionNumber) (shortHeaderPacket, *packetBuffer, error) {
|
func (p *packetPacker) PackAckOnlyPacket(maxPacketSize protocol.ByteCount, now time.Time, v protocol.VersionNumber) (shortHeaderPacket, *packetBuffer, error) {
|
||||||
buf := getPacketBuffer()
|
buf := getPacketBuffer()
|
||||||
packet, err := p.appendPacket(buf, true, maxPacketSize, v)
|
packet, err := p.appendPacket(buf, true, maxPacketSize, now, v)
|
||||||
return packet, buf, err
|
return packet, buf, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// AppendPacket packs a packet in the application data packet number space.
|
// AppendPacket packs a packet in the application data packet number space.
|
||||||
// It should be called after the handshake is confirmed.
|
// It should be called after the handshake is confirmed.
|
||||||
func (p *packetPacker) AppendPacket(buf *packetBuffer, maxPacketSize protocol.ByteCount, v protocol.VersionNumber) (shortHeaderPacket, error) {
|
func (p *packetPacker) AppendPacket(buf *packetBuffer, maxPacketSize protocol.ByteCount, now time.Time, v protocol.VersionNumber) (shortHeaderPacket, error) {
|
||||||
return p.appendPacket(buf, false, maxPacketSize, v)
|
return p.appendPacket(buf, false, maxPacketSize, now, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *packetPacker) appendPacket(buf *packetBuffer, onlyAck bool, maxPacketSize protocol.ByteCount, v protocol.VersionNumber) (shortHeaderPacket, error) {
|
func (p *packetPacker) appendPacket(buf *packetBuffer, onlyAck bool, maxPacketSize protocol.ByteCount, now time.Time, v protocol.VersionNumber) (shortHeaderPacket, error) {
|
||||||
sealer, err := p.cryptoSetup.Get1RTTSealer()
|
sealer, err := p.cryptoSetup.Get1RTTSealer()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return shortHeaderPacket{}, err
|
return shortHeaderPacket{}, err
|
||||||
|
@ -497,7 +498,7 @@ func (p *packetPacker) appendPacket(buf *packetBuffer, onlyAck bool, maxPacketSi
|
||||||
}
|
}
|
||||||
kp := sealer.KeyPhase()
|
kp := sealer.KeyPhase()
|
||||||
|
|
||||||
ap, ack, err := p.appendShortHeaderPacket(buf, connID, pn, pnLen, kp, pl, 0, maxPacketSize, sealer, false, v)
|
ap, ack, err := p.appendShortHeaderPacket(buf, connID, pn, pnLen, kp, pl, 0, maxPacketSize, sealer, false, now, v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return shortHeaderPacket{}, err
|
return shortHeaderPacket{}, err
|
||||||
}
|
}
|
||||||
|
@ -687,7 +688,7 @@ func (p *packetPacker) composeNextPacket(maxFrameSize protocol.ByteCount, onlyAc
|
||||||
return pl
|
return pl
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *packetPacker) MaybePackProbePacket(encLevel protocol.EncryptionLevel, maxPacketSize protocol.ByteCount, v protocol.VersionNumber) (*coalescedPacket, error) {
|
func (p *packetPacker) MaybePackProbePacket(encLevel protocol.EncryptionLevel, maxPacketSize protocol.ByteCount, now time.Time, v protocol.VersionNumber) (*coalescedPacket, error) {
|
||||||
if encLevel == protocol.Encryption1RTT {
|
if encLevel == protocol.Encryption1RTT {
|
||||||
s, err := p.cryptoSetup.Get1RTTSealer()
|
s, err := p.cryptoSetup.Get1RTTSealer()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -703,7 +704,7 @@ func (p *packetPacker) MaybePackProbePacket(encLevel protocol.EncryptionLevel, m
|
||||||
}
|
}
|
||||||
buffer := getPacketBuffer()
|
buffer := getPacketBuffer()
|
||||||
packet := &coalescedPacket{buffer: buffer}
|
packet := &coalescedPacket{buffer: buffer}
|
||||||
ap, ack, err := p.appendShortHeaderPacket(buffer, connID, pn, pnLen, kp, pl, 0, maxPacketSize, s, false, v)
|
ap, ack, err := p.appendShortHeaderPacket(buffer, connID, pn, pnLen, kp, pl, 0, maxPacketSize, s, false, now, v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -773,7 +774,7 @@ func (p *packetPacker) PackMTUProbePacket(ping ackhandler.Frame, size protocol.B
|
||||||
pn, pnLen := p.pnManager.PeekPacketNumber(protocol.Encryption1RTT)
|
pn, pnLen := p.pnManager.PeekPacketNumber(protocol.Encryption1RTT)
|
||||||
padding := size - p.shortHeaderPacketLength(connID, pnLen, pl) - protocol.ByteCount(s.Overhead())
|
padding := size - p.shortHeaderPacketLength(connID, pnLen, pl) - protocol.ByteCount(s.Overhead())
|
||||||
kp := s.KeyPhase()
|
kp := s.KeyPhase()
|
||||||
ap, ack, err := p.appendShortHeaderPacket(buffer, connID, pn, pnLen, kp, pl, padding, size, s, true, v)
|
ap, ack, err := p.appendShortHeaderPacket(buffer, connID, pn, pnLen, kp, pl, padding, size, s, true, now, v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return shortHeaderPacket{}, nil, err
|
return shortHeaderPacket{}, nil, err
|
||||||
}
|
}
|
||||||
|
@ -857,6 +858,7 @@ func (p *packetPacker) appendShortHeaderPacket(
|
||||||
padding, maxPacketSize protocol.ByteCount,
|
padding, maxPacketSize protocol.ByteCount,
|
||||||
sealer sealer,
|
sealer sealer,
|
||||||
isMTUProbePacket bool,
|
isMTUProbePacket bool,
|
||||||
|
now time.Time,
|
||||||
v protocol.VersionNumber,
|
v protocol.VersionNumber,
|
||||||
) (*ackhandler.Packet, *wire.AckFrame, error) {
|
) (*ackhandler.Packet, *wire.AckFrame, error) {
|
||||||
var paddingLen protocol.ByteCount
|
var paddingLen protocol.ByteCount
|
||||||
|
@ -908,7 +910,7 @@ func (p *packetPacker) appendShortHeaderPacket(
|
||||||
ap.StreamFrames = pl.streamFrames
|
ap.StreamFrames = pl.streamFrames
|
||||||
ap.Length = protocol.ByteCount(len(raw))
|
ap.Length = protocol.ByteCount(len(raw))
|
||||||
ap.EncryptionLevel = protocol.Encryption1RTT
|
ap.EncryptionLevel = protocol.Encryption1RTT
|
||||||
ap.SendTime = time.Now()
|
ap.SendTime = now
|
||||||
ap.IsPathMTUProbePacket = isMTUProbePacket
|
ap.IsPathMTUProbePacket = isMTUProbePacket
|
||||||
|
|
||||||
return ap, pl.ack, nil
|
return ap, pl.ack, nil
|
||||||
|
|
|
@ -168,7 +168,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
expectAppendControlFrames()
|
expectAppendControlFrames()
|
||||||
f := &wire.StreamFrame{Data: []byte{0xde, 0xca, 0xfb, 0xad}}
|
f := &wire.StreamFrame{Data: []byte{0xde, 0xca, 0xfb, 0xad}}
|
||||||
expectAppendStreamFrames(ackhandler.StreamFrame{Frame: f})
|
expectAppendStreamFrames(ackhandler.StreamFrame{Frame: f})
|
||||||
p, err := packer.PackCoalescedPacket(false, maxPacketSize, protocol.Version1)
|
p, err := packer.PackCoalescedPacket(false, maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(p).ToNot(BeNil())
|
Expect(p).ToNot(BeNil())
|
||||||
Expect(p.longHdrPackets).To(BeEmpty())
|
Expect(p.longHdrPackets).To(BeEmpty())
|
||||||
|
@ -207,7 +207,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
ackFramer.EXPECT().GetAckFrame(protocol.EncryptionInitial, true)
|
ackFramer.EXPECT().GetAckFrame(protocol.EncryptionInitial, true)
|
||||||
ackFramer.EXPECT().GetAckFrame(protocol.EncryptionHandshake, true)
|
ackFramer.EXPECT().GetAckFrame(protocol.EncryptionHandshake, true)
|
||||||
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, true)
|
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, true)
|
||||||
p, err := packer.PackCoalescedPacket(true, maxPacketSize, protocol.Version1)
|
p, err := packer.PackCoalescedPacket(true, maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(p).To(BeNil())
|
Expect(p).To(BeNil())
|
||||||
})
|
})
|
||||||
|
@ -219,7 +219,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
sealingManager.EXPECT().GetInitialSealer().Return(getSealer(), nil)
|
sealingManager.EXPECT().GetInitialSealer().Return(getSealer(), nil)
|
||||||
ack := &wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 1, Largest: 10}}}
|
ack := &wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 1, Largest: 10}}}
|
||||||
ackFramer.EXPECT().GetAckFrame(protocol.EncryptionInitial, true).Return(ack)
|
ackFramer.EXPECT().GetAckFrame(protocol.EncryptionInitial, true).Return(ack)
|
||||||
p, err := packer.PackCoalescedPacket(true, maxPacketSize, protocol.Version1)
|
p, err := packer.PackCoalescedPacket(true, maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(p).ToNot(BeNil())
|
Expect(p).ToNot(BeNil())
|
||||||
Expect(p.longHdrPackets).To(HaveLen(1))
|
Expect(p.longHdrPackets).To(HaveLen(1))
|
||||||
|
@ -236,7 +236,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
sealingManager.EXPECT().GetInitialSealer().Return(getSealer(), nil)
|
sealingManager.EXPECT().GetInitialSealer().Return(getSealer(), nil)
|
||||||
ack := &wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 1, Largest: 10}}}
|
ack := &wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 1, Largest: 10}}}
|
||||||
ackFramer.EXPECT().GetAckFrame(protocol.EncryptionInitial, true).Return(ack)
|
ackFramer.EXPECT().GetAckFrame(protocol.EncryptionInitial, true).Return(ack)
|
||||||
p, err := packer.PackCoalescedPacket(true, maxPacketSize, protocol.Version1)
|
p, err := packer.PackCoalescedPacket(true, maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(p).ToNot(BeNil())
|
Expect(p).ToNot(BeNil())
|
||||||
Expect(p.longHdrPackets).To(HaveLen(1))
|
Expect(p.longHdrPackets).To(HaveLen(1))
|
||||||
|
@ -256,7 +256,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
ack := &wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 1, Largest: 10}}}
|
ack := &wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 1, Largest: 10}}}
|
||||||
ackFramer.EXPECT().GetAckFrame(protocol.EncryptionHandshake, true)
|
ackFramer.EXPECT().GetAckFrame(protocol.EncryptionHandshake, true)
|
||||||
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, true).Return(ack)
|
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, true).Return(ack)
|
||||||
p, err := packer.PackCoalescedPacket(true, maxPacketSize, protocol.Version1)
|
p, err := packer.PackCoalescedPacket(true, maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(p).ToNot(BeNil())
|
Expect(p).ToNot(BeNil())
|
||||||
Expect(p.longHdrPackets).To(BeEmpty())
|
Expect(p.longHdrPackets).To(BeEmpty())
|
||||||
|
@ -272,7 +272,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
sealingManager.EXPECT().Get1RTTSealer().Return(getSealer(), nil)
|
sealingManager.EXPECT().Get1RTTSealer().Return(getSealer(), nil)
|
||||||
ack := &wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 1, Largest: 10}}}
|
ack := &wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 1, Largest: 10}}}
|
||||||
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, true).Return(ack)
|
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, true).Return(ack)
|
||||||
p, buffer, err := packer.PackAckOnlyPacket(maxPacketSize, protocol.Version1)
|
p, buffer, err := packer.PackAckOnlyPacket(maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(p).ToNot(BeNil())
|
Expect(p).ToNot(BeNil())
|
||||||
Expect(p.Ack).To(Equal(ack))
|
Expect(p.Ack).To(Equal(ack))
|
||||||
|
@ -308,7 +308,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
framer.EXPECT().AppendStreamFrames(gomock.Any(), gomock.Any(), protocol.Version1).DoAndReturn(func(frames []ackhandler.StreamFrame, _ protocol.ByteCount, _ protocol.VersionNumber) ([]ackhandler.StreamFrame, protocol.ByteCount) {
|
framer.EXPECT().AppendStreamFrames(gomock.Any(), gomock.Any(), protocol.Version1).DoAndReturn(func(frames []ackhandler.StreamFrame, _ protocol.ByteCount, _ protocol.VersionNumber) ([]ackhandler.StreamFrame, protocol.ByteCount) {
|
||||||
return frames, 0
|
return frames, 0
|
||||||
})
|
})
|
||||||
p, err := packer.PackCoalescedPacket(false, maxPacketSize, protocol.Version1)
|
p, err := packer.PackCoalescedPacket(false, maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(p).ToNot(BeNil())
|
Expect(p).ToNot(BeNil())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(p.longHdrPackets).To(HaveLen(1))
|
Expect(p.longHdrPackets).To(HaveLen(1))
|
||||||
|
@ -318,7 +318,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
It("doesn't add an ACK-only 0-RTT packet", func() { // ACK frames cannot be sent in 0-RTT packets
|
It("doesn't add an ACK-only 0-RTT packet", func() { // ACK frames cannot be sent in 0-RTT packets
|
||||||
p, err := packer.PackCoalescedPacket(true, protocol.MaxByteCount, protocol.Version1)
|
p, err := packer.PackCoalescedPacket(true, protocol.MaxByteCount, time.Now(), protocol.Version1)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(p).To(BeNil())
|
Expect(p).To(BeNil())
|
||||||
})
|
})
|
||||||
|
@ -333,7 +333,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
sealingManager.EXPECT().Get1RTTSealer().Return(nil, handshake.ErrKeysNotYetAvailable)
|
sealingManager.EXPECT().Get1RTTSealer().Return(nil, handshake.ErrKeysNotYetAvailable)
|
||||||
quicErr := qerr.NewLocalCryptoError(0x42, "crypto error")
|
quicErr := qerr.NewLocalCryptoError(0x42, "crypto error")
|
||||||
quicErr.FrameType = 0x1234
|
quicErr.FrameType = 0x1234
|
||||||
p, err := packer.PackConnectionClose(quicErr, maxPacketSize, protocol.Version1)
|
p, err := packer.PackConnectionClose(quicErr, maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(p.longHdrPackets).To(HaveLen(1))
|
Expect(p.longHdrPackets).To(HaveLen(1))
|
||||||
Expect(p.longHdrPackets[0].header.Type).To(Equal(protocol.PacketTypeHandshake))
|
Expect(p.longHdrPackets[0].header.Type).To(Equal(protocol.PacketTypeHandshake))
|
||||||
|
@ -353,15 +353,17 @@ var _ = Describe("Packet packer", func() {
|
||||||
sealingManager.EXPECT().GetHandshakeSealer().Return(nil, handshake.ErrKeysDropped)
|
sealingManager.EXPECT().GetHandshakeSealer().Return(nil, handshake.ErrKeysDropped)
|
||||||
sealingManager.EXPECT().Get1RTTSealer().Return(getSealer(), nil)
|
sealingManager.EXPECT().Get1RTTSealer().Return(getSealer(), nil)
|
||||||
// expect no framer.PopStreamFrames
|
// expect no framer.PopStreamFrames
|
||||||
|
now := time.Now()
|
||||||
p, err := packer.PackConnectionClose(&qerr.TransportError{
|
p, err := packer.PackConnectionClose(&qerr.TransportError{
|
||||||
ErrorCode: qerr.CryptoBufferExceeded,
|
ErrorCode: qerr.CryptoBufferExceeded,
|
||||||
ErrorMessage: "test error",
|
ErrorMessage: "test error",
|
||||||
}, maxPacketSize, protocol.Version1)
|
}, maxPacketSize, now, protocol.Version1)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(p.longHdrPackets).To(BeEmpty())
|
Expect(p.longHdrPackets).To(BeEmpty())
|
||||||
Expect(p.shortHdrPacket.Frames).To(HaveLen(1))
|
Expect(p.shortHdrPacket.Frames).To(HaveLen(1))
|
||||||
Expect(p.shortHdrPacket.Frames[0].Frame).To(BeAssignableToTypeOf(&wire.ConnectionCloseFrame{}))
|
Expect(p.shortHdrPacket.Frames[0].Frame).To(BeAssignableToTypeOf(&wire.ConnectionCloseFrame{}))
|
||||||
ccf := p.shortHdrPacket.Frames[0].Frame.(*wire.ConnectionCloseFrame)
|
ccf := p.shortHdrPacket.Frames[0].Frame.(*wire.ConnectionCloseFrame)
|
||||||
|
Expect(p.shortHdrPacket.Packet.SendTime).To(Equal(now))
|
||||||
Expect(ccf.IsApplicationError).To(BeFalse())
|
Expect(ccf.IsApplicationError).To(BeFalse())
|
||||||
Expect(ccf.ErrorCode).To(BeEquivalentTo(qerr.CryptoBufferExceeded))
|
Expect(ccf.ErrorCode).To(BeEquivalentTo(qerr.CryptoBufferExceeded))
|
||||||
Expect(ccf.ReasonPhrase).To(Equal("test error"))
|
Expect(ccf.ReasonPhrase).To(Equal("test error"))
|
||||||
|
@ -380,7 +382,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
p, err := packer.PackApplicationClose(&qerr.ApplicationError{
|
p, err := packer.PackApplicationClose(&qerr.ApplicationError{
|
||||||
ErrorCode: 0x1337,
|
ErrorCode: 0x1337,
|
||||||
ErrorMessage: "test error",
|
ErrorMessage: "test error",
|
||||||
}, maxPacketSize, protocol.Version1)
|
}, maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(p.longHdrPackets).To(HaveLen(2))
|
Expect(p.longHdrPackets).To(HaveLen(2))
|
||||||
Expect(p.longHdrPackets[0].header.Type).To(Equal(protocol.PacketTypeInitial))
|
Expect(p.longHdrPackets[0].header.Type).To(Equal(protocol.PacketTypeInitial))
|
||||||
|
@ -422,7 +424,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
p, err := packer.PackApplicationClose(&qerr.ApplicationError{
|
p, err := packer.PackApplicationClose(&qerr.ApplicationError{
|
||||||
ErrorCode: 0x1337,
|
ErrorCode: 0x1337,
|
||||||
ErrorMessage: "test error",
|
ErrorMessage: "test error",
|
||||||
}, maxPacketSize, protocol.Version1)
|
}, maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(p.longHdrPackets).To(HaveLen(1))
|
Expect(p.longHdrPackets).To(HaveLen(1))
|
||||||
Expect(p.buffer.Len()).To(BeNumerically("<", protocol.MinInitialPacketSize))
|
Expect(p.buffer.Len()).To(BeNumerically("<", protocol.MinInitialPacketSize))
|
||||||
|
@ -457,7 +459,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
p, err := packer.PackApplicationClose(&qerr.ApplicationError{
|
p, err := packer.PackApplicationClose(&qerr.ApplicationError{
|
||||||
ErrorCode: 0x1337,
|
ErrorCode: 0x1337,
|
||||||
ErrorMessage: "test error",
|
ErrorMessage: "test error",
|
||||||
}, maxPacketSize, protocol.Version1)
|
}, maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(p.longHdrPackets).To(HaveLen(2))
|
Expect(p.longHdrPackets).To(HaveLen(2))
|
||||||
Expect(p.buffer.Len()).To(BeNumerically(">=", protocol.MinInitialPacketSize))
|
Expect(p.buffer.Len()).To(BeNumerically(">=", protocol.MinInitialPacketSize))
|
||||||
|
@ -493,7 +495,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
sealingManager.EXPECT().Get1RTTSealer().Return(getSealer(), nil)
|
sealingManager.EXPECT().Get1RTTSealer().Return(getSealer(), nil)
|
||||||
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, true)
|
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, true)
|
||||||
framer.EXPECT().HasData()
|
framer.EXPECT().HasData()
|
||||||
_, err := packer.AppendPacket(getPacketBuffer(), maxPacketSize, protocol.Version1)
|
_, err := packer.AppendPacket(getPacketBuffer(), maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(err).To(MatchError(errNothingToPack))
|
Expect(err).To(MatchError(errNothingToPack))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -511,7 +513,8 @@ var _ = Describe("Packet packer", func() {
|
||||||
expectAppendStreamFrames(ackhandler.StreamFrame{Frame: f})
|
expectAppendStreamFrames(ackhandler.StreamFrame{Frame: f})
|
||||||
buffer := getPacketBuffer()
|
buffer := getPacketBuffer()
|
||||||
buffer.Data = append(buffer.Data, []byte("foobar")...)
|
buffer.Data = append(buffer.Data, []byte("foobar")...)
|
||||||
p, err := packer.AppendPacket(buffer, maxPacketSize, protocol.Version1)
|
now := time.Now()
|
||||||
|
p, err := packer.AppendPacket(buffer, maxPacketSize, now, protocol.Version1)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(p).ToNot(BeNil())
|
Expect(p).ToNot(BeNil())
|
||||||
b, err := f.Append(nil, protocol.Version1)
|
b, err := f.Append(nil, protocol.Version1)
|
||||||
|
@ -519,6 +522,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
Expect(p.Frames).To(BeEmpty())
|
Expect(p.Frames).To(BeEmpty())
|
||||||
Expect(p.StreamFrames).To(HaveLen(1))
|
Expect(p.StreamFrames).To(HaveLen(1))
|
||||||
Expect(p.StreamFrames[0].Frame.StreamID).To(Equal(f.StreamID))
|
Expect(p.StreamFrames[0].Frame.StreamID).To(Equal(f.StreamID))
|
||||||
|
Expect(p.Packet.SendTime).To(Equal(now))
|
||||||
Expect(buffer.Data[:6]).To(Equal([]byte("foobar"))) // make sure the packet was actually appended
|
Expect(buffer.Data[:6]).To(Equal([]byte("foobar"))) // make sure the packet was actually appended
|
||||||
Expect(buffer.Data).To(ContainSubstring(string(b)))
|
Expect(buffer.Data).To(ContainSubstring(string(b)))
|
||||||
})
|
})
|
||||||
|
@ -530,7 +534,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
framer.EXPECT().HasData()
|
framer.EXPECT().HasData()
|
||||||
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, true).Return(ack)
|
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, true).Return(ack)
|
||||||
sealingManager.EXPECT().Get1RTTSealer().Return(getSealer(), nil)
|
sealingManager.EXPECT().Get1RTTSealer().Return(getSealer(), nil)
|
||||||
p, err := packer.AppendPacket(getPacketBuffer(), maxPacketSize, protocol.Version1)
|
p, err := packer.AppendPacket(getPacketBuffer(), maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(p).ToNot(BeNil())
|
Expect(p).ToNot(BeNil())
|
||||||
Expect(p.Ack).To(Equal(ack))
|
Expect(p.Ack).To(Equal(ack))
|
||||||
|
@ -549,7 +553,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
expectAppendControlFrames(frames...)
|
expectAppendControlFrames(frames...)
|
||||||
expectAppendStreamFrames()
|
expectAppendStreamFrames()
|
||||||
buffer := getPacketBuffer()
|
buffer := getPacketBuffer()
|
||||||
p, err := packer.AppendPacket(buffer, maxPacketSize, protocol.Version1)
|
p, err := packer.AppendPacket(buffer, maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(p).ToNot(BeNil())
|
Expect(p).ToNot(BeNil())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(p.Frames).To(HaveLen(2))
|
Expect(p.Frames).To(HaveLen(2))
|
||||||
|
@ -579,7 +583,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
|
|
||||||
framer.EXPECT().HasData()
|
framer.EXPECT().HasData()
|
||||||
buffer := getPacketBuffer()
|
buffer := getPacketBuffer()
|
||||||
p, err := packer.AppendPacket(buffer, maxPacketSize, protocol.Version1)
|
p, err := packer.AppendPacket(buffer, maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(p).ToNot(BeNil())
|
Expect(p).ToNot(BeNil())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(p.Frames).To(HaveLen(1))
|
Expect(p.Frames).To(HaveLen(1))
|
||||||
|
@ -608,7 +612,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
|
|
||||||
framer.EXPECT().HasData()
|
framer.EXPECT().HasData()
|
||||||
buffer := getPacketBuffer()
|
buffer := getPacketBuffer()
|
||||||
p, err := packer.AppendPacket(buffer, maxPacketSize, protocol.Version1)
|
p, err := packer.AppendPacket(buffer, maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(p).ToNot(BeNil())
|
Expect(p).ToNot(BeNil())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(p.Ack).ToNot(BeNil())
|
Expect(p.Ack).ToNot(BeNil())
|
||||||
|
@ -634,7 +638,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
return fs, 0
|
return fs, 0
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
_, err := packer.AppendPacket(getPacketBuffer(), maxPacketSize, protocol.Version1)
|
_, err := packer.AppendPacket(getPacketBuffer(), maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(err).To(MatchError(errNothingToPack))
|
Expect(err).To(MatchError(errNothingToPack))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -648,7 +652,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
packer.retransmissionQueue.AddHandshake(&wire.PingFrame{})
|
packer.retransmissionQueue.AddHandshake(&wire.PingFrame{})
|
||||||
handshakeStream.EXPECT().HasData()
|
handshakeStream.EXPECT().HasData()
|
||||||
ackFramer.EXPECT().GetAckFrame(protocol.EncryptionHandshake, false)
|
ackFramer.EXPECT().GetAckFrame(protocol.EncryptionHandshake, false)
|
||||||
packet, err := packer.PackCoalescedPacket(false, maxPacketSize, protocol.Version1)
|
packet, err := packer.PackCoalescedPacket(false, maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(packet).ToNot(BeNil())
|
Expect(packet).ToNot(BeNil())
|
||||||
Expect(packet.longHdrPackets).To(HaveLen(1))
|
Expect(packet.longHdrPackets).To(HaveLen(1))
|
||||||
|
@ -692,7 +696,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
expectAppendControlFrames()
|
expectAppendControlFrames()
|
||||||
expectAppendStreamFrames(ackhandler.StreamFrame{Frame: f})
|
expectAppendStreamFrames(ackhandler.StreamFrame{Frame: f})
|
||||||
buffer := getPacketBuffer()
|
buffer := getPacketBuffer()
|
||||||
_, err := packer.AppendPacket(buffer, maxPacketSize, protocol.Version1)
|
_, err := packer.AppendPacket(buffer, maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
// cut off the tag that the mock sealer added
|
// cut off the tag that the mock sealer added
|
||||||
buffer.Data = buffer.Data[:buffer.Len()-protocol.ByteCount(sealer.Overhead())]
|
buffer.Data = buffer.Data[:buffer.Len()-protocol.ByteCount(sealer.Overhead())]
|
||||||
|
@ -741,7 +745,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, false)
|
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, false)
|
||||||
expectAppendControlFrames()
|
expectAppendControlFrames()
|
||||||
expectAppendStreamFrames(ackhandler.StreamFrame{Frame: f1}, ackhandler.StreamFrame{Frame: f2}, ackhandler.StreamFrame{Frame: f3})
|
expectAppendStreamFrames(ackhandler.StreamFrame{Frame: f1}, ackhandler.StreamFrame{Frame: f2}, ackhandler.StreamFrame{Frame: f3})
|
||||||
p, err := packer.AppendPacket(getPacketBuffer(), maxPacketSize, protocol.Version1)
|
p, err := packer.AppendPacket(getPacketBuffer(), maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(p).ToNot(BeNil())
|
Expect(p).ToNot(BeNil())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(p.Frames).To(BeEmpty())
|
Expect(p.Frames).To(BeEmpty())
|
||||||
|
@ -761,7 +765,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, false).Return(&wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 1, Largest: 1}}})
|
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, false).Return(&wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 1, Largest: 1}}})
|
||||||
expectAppendControlFrames()
|
expectAppendControlFrames()
|
||||||
expectAppendStreamFrames()
|
expectAppendStreamFrames()
|
||||||
p, err := packer.AppendPacket(getPacketBuffer(), maxPacketSize, protocol.Version1)
|
p, err := packer.AppendPacket(getPacketBuffer(), maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(p).ToNot(BeNil())
|
Expect(p).ToNot(BeNil())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(p.Ack).ToNot(BeNil())
|
Expect(p.Ack).ToNot(BeNil())
|
||||||
|
@ -778,7 +782,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, false).Return(&wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 1, Largest: 1}}})
|
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, false).Return(&wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 1, Largest: 1}}})
|
||||||
expectAppendControlFrames()
|
expectAppendControlFrames()
|
||||||
expectAppendStreamFrames()
|
expectAppendStreamFrames()
|
||||||
p, err := packer.AppendPacket(getPacketBuffer(), maxPacketSize, protocol.Version1)
|
p, err := packer.AppendPacket(getPacketBuffer(), maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(p).ToNot(BeNil())
|
Expect(p).ToNot(BeNil())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
var hasPing bool
|
var hasPing bool
|
||||||
|
@ -797,7 +801,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, false).Return(&wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 1, Largest: 1}}})
|
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, false).Return(&wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 1, Largest: 1}}})
|
||||||
expectAppendControlFrames()
|
expectAppendControlFrames()
|
||||||
expectAppendStreamFrames()
|
expectAppendStreamFrames()
|
||||||
p, err = packer.AppendPacket(getPacketBuffer(), maxPacketSize, protocol.Version1)
|
p, err = packer.AppendPacket(getPacketBuffer(), maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(p).ToNot(BeNil())
|
Expect(p).ToNot(BeNil())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(p.Ack).ToNot(BeNil())
|
Expect(p.Ack).ToNot(BeNil())
|
||||||
|
@ -813,7 +817,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
expectAppendControlFrames()
|
expectAppendControlFrames()
|
||||||
expectAppendStreamFrames()
|
expectAppendStreamFrames()
|
||||||
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, false)
|
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, false)
|
||||||
_, err := packer.AppendPacket(getPacketBuffer(), maxPacketSize, protocol.Version1)
|
_, err := packer.AppendPacket(getPacketBuffer(), maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(err).To(MatchError(errNothingToPack))
|
Expect(err).To(MatchError(errNothingToPack))
|
||||||
// now add some frame to send
|
// now add some frame to send
|
||||||
expectAppendControlFrames()
|
expectAppendControlFrames()
|
||||||
|
@ -824,7 +828,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
framer.EXPECT().HasData().Return(true)
|
framer.EXPECT().HasData().Return(true)
|
||||||
ack := &wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 1, Largest: 1}}}
|
ack := &wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 1, Largest: 1}}}
|
||||||
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, false).Return(ack)
|
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, false).Return(ack)
|
||||||
p, err := packer.AppendPacket(getPacketBuffer(), maxPacketSize, protocol.Version1)
|
p, err := packer.AppendPacket(getPacketBuffer(), maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(p.Ack).To(Equal(ack))
|
Expect(p.Ack).To(Equal(ack))
|
||||||
var hasPing bool
|
var hasPing bool
|
||||||
|
@ -846,7 +850,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, false)
|
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, false)
|
||||||
expectAppendStreamFrames()
|
expectAppendStreamFrames()
|
||||||
expectAppendControlFrames(ackhandler.Frame{Frame: &wire.MaxDataFrame{}})
|
expectAppendControlFrames(ackhandler.Frame{Frame: &wire.MaxDataFrame{}})
|
||||||
p, err := packer.AppendPacket(getPacketBuffer(), maxPacketSize, protocol.Version1)
|
p, err := packer.AppendPacket(getPacketBuffer(), maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(p).ToNot(BeNil())
|
Expect(p).ToNot(BeNil())
|
||||||
Expect(p.Frames).ToNot(ContainElement(&wire.PingFrame{}))
|
Expect(p.Frames).ToNot(ContainElement(&wire.PingFrame{}))
|
||||||
|
@ -868,7 +872,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
sealingManager.EXPECT().GetInitialSealer().Return(nil, handshake.ErrKeysDropped)
|
sealingManager.EXPECT().GetInitialSealer().Return(nil, handshake.ErrKeysDropped)
|
||||||
sealingManager.EXPECT().GetHandshakeSealer().Return(getSealer(), nil)
|
sealingManager.EXPECT().GetHandshakeSealer().Return(getSealer(), nil)
|
||||||
sealingManager.EXPECT().Get1RTTSealer().Return(nil, handshake.ErrKeysNotYetAvailable)
|
sealingManager.EXPECT().Get1RTTSealer().Return(nil, handshake.ErrKeysNotYetAvailable)
|
||||||
p, err := packer.PackCoalescedPacket(false, maxPacketSize, protocol.Version1)
|
p, err := packer.PackCoalescedPacket(false, maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(p).ToNot(BeNil())
|
Expect(p).ToNot(BeNil())
|
||||||
parsePacket(p.buffer.Data)
|
parsePacket(p.buffer.Data)
|
||||||
|
@ -887,7 +891,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
initialStream.EXPECT().PopCryptoFrame(gomock.Any()).DoAndReturn(func(size protocol.ByteCount) *wire.CryptoFrame {
|
initialStream.EXPECT().PopCryptoFrame(gomock.Any()).DoAndReturn(func(size protocol.ByteCount) *wire.CryptoFrame {
|
||||||
return &wire.CryptoFrame{Offset: 0x42, Data: []byte("initial")}
|
return &wire.CryptoFrame{Offset: 0x42, Data: []byte("initial")}
|
||||||
})
|
})
|
||||||
p, err := packer.PackCoalescedPacket(false, maxPacketSize, protocol.Version1)
|
p, err := packer.PackCoalescedPacket(false, maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(p.buffer.Len()).To(BeNumerically(">=", protocol.MinInitialPacketSize))
|
Expect(p.buffer.Len()).To(BeNumerically(">=", protocol.MinInitialPacketSize))
|
||||||
Expect(p.buffer.Len()).To(BeEquivalentTo(maxPacketSize))
|
Expect(p.buffer.Len()).To(BeEquivalentTo(maxPacketSize))
|
||||||
|
@ -917,7 +921,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
Expect(f.Length(protocol.Version1)).To(Equal(size))
|
Expect(f.Length(protocol.Version1)).To(Equal(size))
|
||||||
return f
|
return f
|
||||||
})
|
})
|
||||||
p, err := packer.PackCoalescedPacket(false, maxPacketSize, protocol.Version1)
|
p, err := packer.PackCoalescedPacket(false, maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(p.longHdrPackets).To(HaveLen(1))
|
Expect(p.longHdrPackets).To(HaveLen(1))
|
||||||
Expect(p.longHdrPackets[0].frames).To(HaveLen(1))
|
Expect(p.longHdrPackets[0].frames).To(HaveLen(1))
|
||||||
|
@ -943,7 +947,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
handshakeStream.EXPECT().PopCryptoFrame(gomock.Any()).DoAndReturn(func(size protocol.ByteCount) *wire.CryptoFrame {
|
handshakeStream.EXPECT().PopCryptoFrame(gomock.Any()).DoAndReturn(func(size protocol.ByteCount) *wire.CryptoFrame {
|
||||||
return &wire.CryptoFrame{Offset: 0x1337, Data: []byte("handshake")}
|
return &wire.CryptoFrame{Offset: 0x1337, Data: []byte("handshake")}
|
||||||
})
|
})
|
||||||
p, err := packer.PackCoalescedPacket(false, maxPacketSize, protocol.Version1)
|
p, err := packer.PackCoalescedPacket(false, maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(p.buffer.Len()).To(BeEquivalentTo(maxPacketSize))
|
Expect(p.buffer.Len()).To(BeEquivalentTo(maxPacketSize))
|
||||||
Expect(p.longHdrPackets).To(HaveLen(2))
|
Expect(p.longHdrPackets).To(HaveLen(2))
|
||||||
|
@ -977,7 +981,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
})
|
})
|
||||||
handshakeStream.EXPECT().HasData()
|
handshakeStream.EXPECT().HasData()
|
||||||
packer.retransmissionQueue.AddHandshake(&wire.PingFrame{})
|
packer.retransmissionQueue.AddHandshake(&wire.PingFrame{})
|
||||||
p, err := packer.PackCoalescedPacket(false, maxPacketSize, protocol.Version1)
|
p, err := packer.PackCoalescedPacket(false, maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(p.buffer.Len()).To(BeEquivalentTo(maxPacketSize))
|
Expect(p.buffer.Len()).To(BeEquivalentTo(maxPacketSize))
|
||||||
Expect(p.longHdrPackets).To(HaveLen(2))
|
Expect(p.longHdrPackets).To(HaveLen(2))
|
||||||
|
@ -1008,7 +1012,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
handshakeStream.EXPECT().HasData()
|
handshakeStream.EXPECT().HasData()
|
||||||
packer.retransmissionQueue.AddInitial(&wire.PingFrame{})
|
packer.retransmissionQueue.AddInitial(&wire.PingFrame{})
|
||||||
packer.retransmissionQueue.AddHandshake(&wire.PingFrame{})
|
packer.retransmissionQueue.AddHandshake(&wire.PingFrame{})
|
||||||
p, err := packer.PackCoalescedPacket(false, maxPacketSize, protocol.Version1)
|
p, err := packer.PackCoalescedPacket(false, maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(p.buffer.Len()).To(BeEquivalentTo(maxPacketSize))
|
Expect(p.buffer.Len()).To(BeEquivalentTo(maxPacketSize))
|
||||||
Expect(p.longHdrPackets).To(HaveLen(2))
|
Expect(p.longHdrPackets).To(HaveLen(2))
|
||||||
|
@ -1042,7 +1046,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
expectAppendStreamFrames()
|
expectAppendStreamFrames()
|
||||||
framer.EXPECT().HasData().Return(true)
|
framer.EXPECT().HasData().Return(true)
|
||||||
packer.retransmissionQueue.AddAppData(&wire.PingFrame{})
|
packer.retransmissionQueue.AddAppData(&wire.PingFrame{})
|
||||||
p, err := packer.PackCoalescedPacket(false, maxPacketSize, protocol.Version1)
|
p, err := packer.PackCoalescedPacket(false, maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(p.buffer.Len()).To(BeEquivalentTo(maxPacketSize))
|
Expect(p.buffer.Len()).To(BeEquivalentTo(maxPacketSize))
|
||||||
Expect(p.longHdrPackets).To(HaveLen(1))
|
Expect(p.longHdrPackets).To(HaveLen(1))
|
||||||
|
@ -1078,7 +1082,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
})
|
})
|
||||||
expectAppendControlFrames()
|
expectAppendControlFrames()
|
||||||
expectAppendStreamFrames(ackhandler.StreamFrame{Frame: &wire.StreamFrame{Data: []byte("foobar")}})
|
expectAppendStreamFrames(ackhandler.StreamFrame{Frame: &wire.StreamFrame{Data: []byte("foobar")}})
|
||||||
p, err := packer.PackCoalescedPacket(false, maxPacketSize, protocol.Version1)
|
p, err := packer.PackCoalescedPacket(false, maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(p.buffer.Len()).To(BeNumerically(">=", protocol.MinInitialPacketSize))
|
Expect(p.buffer.Len()).To(BeNumerically(">=", protocol.MinInitialPacketSize))
|
||||||
Expect(p.buffer.Len()).To(BeEquivalentTo(maxPacketSize))
|
Expect(p.buffer.Len()).To(BeEquivalentTo(maxPacketSize))
|
||||||
|
@ -1115,7 +1119,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
})
|
})
|
||||||
expectAppendControlFrames()
|
expectAppendControlFrames()
|
||||||
expectAppendStreamFrames(ackhandler.StreamFrame{Frame: &wire.StreamFrame{Data: []byte("foobar")}})
|
expectAppendStreamFrames(ackhandler.StreamFrame{Frame: &wire.StreamFrame{Data: []byte("foobar")}})
|
||||||
p, err := packer.PackCoalescedPacket(false, maxPacketSize, protocol.Version1)
|
p, err := packer.PackCoalescedPacket(false, maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(p.buffer.Len()).To(BeNumerically("<", 100))
|
Expect(p.buffer.Len()).To(BeNumerically("<", 100))
|
||||||
Expect(p.longHdrPackets).To(HaveLen(1))
|
Expect(p.longHdrPackets).To(HaveLen(1))
|
||||||
|
@ -1148,7 +1152,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
Expect(f.Length(protocol.Version1)).To(Equal(s))
|
Expect(f.Length(protocol.Version1)).To(Equal(s))
|
||||||
return f
|
return f
|
||||||
})
|
})
|
||||||
p, err := packer.PackCoalescedPacket(false, maxPacketSize, protocol.Version1)
|
p, err := packer.PackCoalescedPacket(false, maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(p.longHdrPackets).To(HaveLen(1))
|
Expect(p.longHdrPackets).To(HaveLen(1))
|
||||||
Expect(p.shortHdrPacket).To(BeNil())
|
Expect(p.shortHdrPacket).To(BeNil())
|
||||||
|
@ -1167,7 +1171,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
packer.retransmissionQueue.AddHandshake(&wire.PingFrame{})
|
packer.retransmissionQueue.AddHandshake(&wire.PingFrame{})
|
||||||
handshakeStream.EXPECT().HasData()
|
handshakeStream.EXPECT().HasData()
|
||||||
ackFramer.EXPECT().GetAckFrame(protocol.EncryptionHandshake, false)
|
ackFramer.EXPECT().GetAckFrame(protocol.EncryptionHandshake, false)
|
||||||
packet, err := packer.PackCoalescedPacket(false, maxPacketSize, protocol.Version1)
|
packet, err := packer.PackCoalescedPacket(false, maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(packet).ToNot(BeNil())
|
Expect(packet).ToNot(BeNil())
|
||||||
Expect(packet.longHdrPackets).To(HaveLen(1))
|
Expect(packet.longHdrPackets).To(HaveLen(1))
|
||||||
|
@ -1208,7 +1212,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
sealingManager.EXPECT().Get1RTTSealer().Return(nil, handshake.ErrKeysNotYetAvailable)
|
sealingManager.EXPECT().Get1RTTSealer().Return(nil, handshake.ErrKeysNotYetAvailable)
|
||||||
ackFramer.EXPECT().GetAckFrame(protocol.EncryptionInitial, false)
|
ackFramer.EXPECT().GetAckFrame(protocol.EncryptionInitial, false)
|
||||||
initialStream.EXPECT().HasData()
|
initialStream.EXPECT().HasData()
|
||||||
p, err := packer.PackCoalescedPacket(false, maxPacketSize, protocol.Version1)
|
p, err := packer.PackCoalescedPacket(false, maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(p.longHdrPackets).To(HaveLen(1))
|
Expect(p.longHdrPackets).To(HaveLen(1))
|
||||||
Expect(p.longHdrPackets[0].EncryptionLevel()).To(Equal(protocol.EncryptionInitial))
|
Expect(p.longHdrPackets[0].EncryptionLevel()).To(Equal(protocol.EncryptionInitial))
|
||||||
|
@ -1224,7 +1228,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
sealingManager.EXPECT().Get1RTTSealer().Return(nil, handshake.ErrKeysNotYetAvailable)
|
sealingManager.EXPECT().Get1RTTSealer().Return(nil, handshake.ErrKeysNotYetAvailable)
|
||||||
pnManager.EXPECT().PeekPacketNumber(protocol.EncryptionInitial).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2)
|
pnManager.EXPECT().PeekPacketNumber(protocol.EncryptionInitial).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2)
|
||||||
pnManager.EXPECT().PopPacketNumber(protocol.EncryptionInitial).Return(protocol.PacketNumber(0x42))
|
pnManager.EXPECT().PopPacketNumber(protocol.EncryptionInitial).Return(protocol.PacketNumber(0x42))
|
||||||
p, err := packer.PackCoalescedPacket(false, maxPacketSize, protocol.Version1)
|
p, err := packer.PackCoalescedPacket(false, maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(p.longHdrPackets).To(HaveLen(1))
|
Expect(p.longHdrPackets).To(HaveLen(1))
|
||||||
Expect(p.longHdrPackets[0].ack).To(Equal(ack))
|
Expect(p.longHdrPackets[0].ack).To(Equal(ack))
|
||||||
|
@ -1236,7 +1240,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
sealingManager.EXPECT().Get1RTTSealer().Return(nil, handshake.ErrKeysNotYetAvailable)
|
sealingManager.EXPECT().Get1RTTSealer().Return(nil, handshake.ErrKeysNotYetAvailable)
|
||||||
initialStream.EXPECT().HasData()
|
initialStream.EXPECT().HasData()
|
||||||
ackFramer.EXPECT().GetAckFrame(protocol.EncryptionInitial, true)
|
ackFramer.EXPECT().GetAckFrame(protocol.EncryptionInitial, true)
|
||||||
p, err := packer.PackCoalescedPacket(false, maxPacketSize, protocol.Version1)
|
p, err := packer.PackCoalescedPacket(false, maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(p).To(BeNil())
|
Expect(p).To(BeNil())
|
||||||
})
|
})
|
||||||
|
@ -1252,7 +1256,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
sealingManager.EXPECT().Get1RTTSealer().Return(nil, handshake.ErrKeysNotYetAvailable)
|
sealingManager.EXPECT().Get1RTTSealer().Return(nil, handshake.ErrKeysNotYetAvailable)
|
||||||
pnManager.EXPECT().PeekPacketNumber(protocol.EncryptionHandshake).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2)
|
pnManager.EXPECT().PeekPacketNumber(protocol.EncryptionHandshake).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2)
|
||||||
pnManager.EXPECT().PopPacketNumber(protocol.EncryptionHandshake).Return(protocol.PacketNumber(0x42))
|
pnManager.EXPECT().PopPacketNumber(protocol.EncryptionHandshake).Return(protocol.PacketNumber(0x42))
|
||||||
p, err := packer.PackCoalescedPacket(false, maxPacketSize, protocol.Version1)
|
p, err := packer.PackCoalescedPacket(false, maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(p.longHdrPackets).To(HaveLen(1))
|
Expect(p.longHdrPackets).To(HaveLen(1))
|
||||||
Expect(p.longHdrPackets[0].ack).To(Equal(ack))
|
Expect(p.longHdrPackets[0].ack).To(Equal(ack))
|
||||||
|
@ -1275,7 +1279,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
initialStream.EXPECT().HasData().Return(true).Times(2)
|
initialStream.EXPECT().HasData().Return(true).Times(2)
|
||||||
initialStream.EXPECT().PopCryptoFrame(gomock.Any()).Return(f)
|
initialStream.EXPECT().PopCryptoFrame(gomock.Any()).Return(f)
|
||||||
packer.perspective = protocol.PerspectiveClient
|
packer.perspective = protocol.PerspectiveClient
|
||||||
p, err := packer.PackCoalescedPacket(false, maxPacketSize, protocol.Version1)
|
p, err := packer.PackCoalescedPacket(false, maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(p.buffer.Len()).To(BeNumerically(">=", protocol.MinInitialPacketSize))
|
Expect(p.buffer.Len()).To(BeNumerically(">=", protocol.MinInitialPacketSize))
|
||||||
Expect(p.buffer.Len()).To(BeEquivalentTo(maxPacketSize))
|
Expect(p.buffer.Len()).To(BeEquivalentTo(maxPacketSize))
|
||||||
|
@ -1300,7 +1304,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
initialStream.EXPECT().HasData().Return(true).Times(2)
|
initialStream.EXPECT().HasData().Return(true).Times(2)
|
||||||
initialStream.EXPECT().PopCryptoFrame(gomock.Any()).Return(f)
|
initialStream.EXPECT().PopCryptoFrame(gomock.Any()).Return(f)
|
||||||
packer.perspective = protocol.PerspectiveClient
|
packer.perspective = protocol.PerspectiveClient
|
||||||
p, err := packer.PackCoalescedPacket(false, maxPacketSize, protocol.Version1)
|
p, err := packer.PackCoalescedPacket(false, maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(p.longHdrPackets).To(HaveLen(1))
|
Expect(p.longHdrPackets).To(HaveLen(1))
|
||||||
Expect(p.longHdrPackets[0].ack).To(Equal(ack))
|
Expect(p.longHdrPackets[0].ack).To(Equal(ack))
|
||||||
|
@ -1323,7 +1327,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
pnManager.EXPECT().PeekPacketNumber(protocol.EncryptionInitial).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2)
|
pnManager.EXPECT().PeekPacketNumber(protocol.EncryptionInitial).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2)
|
||||||
pnManager.EXPECT().PopPacketNumber(protocol.EncryptionInitial).Return(protocol.PacketNumber(0x42))
|
pnManager.EXPECT().PopPacketNumber(protocol.EncryptionInitial).Return(protocol.PacketNumber(0x42))
|
||||||
|
|
||||||
p, err := packer.MaybePackProbePacket(protocol.EncryptionInitial, maxPacketSize, protocol.Version1)
|
p, err := packer.MaybePackProbePacket(protocol.EncryptionInitial, maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(p).ToNot(BeNil())
|
Expect(p).ToNot(BeNil())
|
||||||
Expect(p.longHdrPackets).To(HaveLen(1))
|
Expect(p.longHdrPackets).To(HaveLen(1))
|
||||||
|
@ -1345,7 +1349,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
pnManager.EXPECT().PeekPacketNumber(protocol.EncryptionInitial).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen1)
|
pnManager.EXPECT().PeekPacketNumber(protocol.EncryptionInitial).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen1)
|
||||||
pnManager.EXPECT().PopPacketNumber(protocol.EncryptionInitial).Return(protocol.PacketNumber(0x42))
|
pnManager.EXPECT().PopPacketNumber(protocol.EncryptionInitial).Return(protocol.PacketNumber(0x42))
|
||||||
|
|
||||||
p, err := packer.MaybePackProbePacket(protocol.EncryptionInitial, maxPacketSize, protocol.Version1)
|
p, err := packer.MaybePackProbePacket(protocol.EncryptionInitial, maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(p).ToNot(BeNil())
|
Expect(p).ToNot(BeNil())
|
||||||
|
@ -1369,7 +1373,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
pnManager.EXPECT().PeekPacketNumber(protocol.EncryptionHandshake).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2)
|
pnManager.EXPECT().PeekPacketNumber(protocol.EncryptionHandshake).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2)
|
||||||
pnManager.EXPECT().PopPacketNumber(protocol.EncryptionHandshake).Return(protocol.PacketNumber(0x42))
|
pnManager.EXPECT().PopPacketNumber(protocol.EncryptionHandshake).Return(protocol.PacketNumber(0x42))
|
||||||
|
|
||||||
p, err := packer.MaybePackProbePacket(protocol.EncryptionHandshake, maxPacketSize, protocol.Version1)
|
p, err := packer.MaybePackProbePacket(protocol.EncryptionHandshake, maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(p).ToNot(BeNil())
|
Expect(p).ToNot(BeNil())
|
||||||
|
@ -1390,7 +1394,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
pnManager.EXPECT().PeekPacketNumber(protocol.EncryptionHandshake).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2)
|
pnManager.EXPECT().PeekPacketNumber(protocol.EncryptionHandshake).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2)
|
||||||
pnManager.EXPECT().PopPacketNumber(protocol.EncryptionHandshake).Return(protocol.PacketNumber(0x42))
|
pnManager.EXPECT().PopPacketNumber(protocol.EncryptionHandshake).Return(protocol.PacketNumber(0x42))
|
||||||
|
|
||||||
p, err := packer.MaybePackProbePacket(protocol.EncryptionHandshake, maxPacketSize, protocol.Version1)
|
p, err := packer.MaybePackProbePacket(protocol.EncryptionHandshake, maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(p).ToNot(BeNil())
|
Expect(p).ToNot(BeNil())
|
||||||
|
@ -1414,7 +1418,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
expectAppendControlFrames()
|
expectAppendControlFrames()
|
||||||
expectAppendStreamFrames(ackhandler.StreamFrame{Frame: f})
|
expectAppendStreamFrames(ackhandler.StreamFrame{Frame: f})
|
||||||
|
|
||||||
p, err := packer.MaybePackProbePacket(protocol.Encryption1RTT, maxPacketSize, protocol.Version1)
|
p, err := packer.MaybePackProbePacket(protocol.Encryption1RTT, maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(p).ToNot(BeNil())
|
Expect(p).ToNot(BeNil())
|
||||||
Expect(p.longHdrPackets).To(BeEmpty())
|
Expect(p.longHdrPackets).To(BeEmpty())
|
||||||
|
@ -1440,7 +1444,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
return append(fs, ackhandler.StreamFrame{Frame: sf}), sf.Length(v)
|
return append(fs, ackhandler.StreamFrame{Frame: sf}), sf.Length(v)
|
||||||
})
|
})
|
||||||
|
|
||||||
p, err := packer.MaybePackProbePacket(protocol.Encryption1RTT, maxPacketSize, protocol.Version1)
|
p, err := packer.MaybePackProbePacket(protocol.Encryption1RTT, maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(p).ToNot(BeNil())
|
Expect(p).ToNot(BeNil())
|
||||||
Expect(p.longHdrPackets).To(BeEmpty())
|
Expect(p.longHdrPackets).To(BeEmpty())
|
||||||
|
@ -1457,7 +1461,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, true)
|
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, true)
|
||||||
framer.EXPECT().HasData()
|
framer.EXPECT().HasData()
|
||||||
|
|
||||||
packet, err := packer.MaybePackProbePacket(protocol.Encryption1RTT, maxPacketSize, protocol.Version1)
|
packet, err := packer.MaybePackProbePacket(protocol.Encryption1RTT, maxPacketSize, time.Now(), protocol.Version1)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(packet).To(BeNil())
|
Expect(packet).To(BeNil())
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue