forked from quic-go/quic-go
use a different network timeout before the crypto handshake completes
ref #320
This commit is contained in:
11
session.go
11
session.go
@@ -200,7 +200,7 @@ func (s *Session) run() {
|
|||||||
if err := s.sendPacket(); err != nil {
|
if err := s.sendPacket(); err != nil {
|
||||||
s.Close(err)
|
s.Close(err)
|
||||||
}
|
}
|
||||||
if time.Now().Sub(s.lastNetworkActivityTime) >= s.connectionParametersManager.GetIdleConnectionStateLifetime() {
|
if time.Now().Sub(s.lastNetworkActivityTime) >= s.idleTimeout() {
|
||||||
s.Close(qerr.Error(qerr.NetworkIdleTimeout, "No recent network activity."))
|
s.Close(qerr.Error(qerr.NetworkIdleTimeout, "No recent network activity."))
|
||||||
}
|
}
|
||||||
if !s.cryptoSetup.HandshakeComplete() && time.Now().Sub(s.sessionCreationTime) >= protocol.MaxTimeForCryptoHandshake {
|
if !s.cryptoSetup.HandshakeComplete() && time.Now().Sub(s.sessionCreationTime) >= protocol.MaxTimeForCryptoHandshake {
|
||||||
@@ -211,7 +211,7 @@ func (s *Session) run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Session) maybeResetTimer() {
|
func (s *Session) maybeResetTimer() {
|
||||||
nextDeadline := s.lastNetworkActivityTime.Add(s.connectionParametersManager.GetIdleConnectionStateLifetime())
|
nextDeadline := s.lastNetworkActivityTime.Add(s.idleTimeout())
|
||||||
|
|
||||||
if !s.delayedAckOriginTime.IsZero() {
|
if !s.delayedAckOriginTime.IsZero() {
|
||||||
nextDeadline = utils.MinTime(nextDeadline, s.delayedAckOriginTime.Add(protocol.AckSendDelay))
|
nextDeadline = utils.MinTime(nextDeadline, s.delayedAckOriginTime.Add(protocol.AckSendDelay))
|
||||||
@@ -240,6 +240,13 @@ func (s *Session) maybeResetTimer() {
|
|||||||
s.currentDeadline = nextDeadline
|
s.currentDeadline = nextDeadline
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Session) idleTimeout() time.Duration {
|
||||||
|
if s.cryptoSetup.HandshakeComplete() {
|
||||||
|
return s.connectionParametersManager.GetIdleConnectionStateLifetime()
|
||||||
|
}
|
||||||
|
return protocol.InitialIdleTimeout
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Session) handlePacketImpl(p *receivedPacket) error {
|
func (s *Session) handlePacketImpl(p *receivedPacket) error {
|
||||||
if p.rcvTime.IsZero() {
|
if p.rcvTime.IsZero() {
|
||||||
// To simplify testing
|
// To simplify testing
|
||||||
|
|||||||
@@ -762,6 +762,30 @@ var _ = Describe("Session", func() {
|
|||||||
Expect(conn.written[0]).To(ContainSubstring("Crypto handshake did not complete in time."))
|
Expect(conn.written[0]).To(ContainSubstring("Crypto handshake did not complete in time."))
|
||||||
close(done)
|
close(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("does not use ICSL before handshake", func(done Done) {
|
||||||
|
session.lastNetworkActivityTime = time.Now().Add(-time.Minute)
|
||||||
|
session.connectionParametersManager.SetFromMap(map[handshake.Tag][]byte{
|
||||||
|
handshake.TagICSL: {0xff, 0xff, 0xff, 0xff},
|
||||||
|
})
|
||||||
|
session.packer.connectionParametersManager = session.connectionParametersManager
|
||||||
|
session.run() // Would normally not return
|
||||||
|
Expect(conn.written[0]).To(ContainSubstring("No recent network activity."))
|
||||||
|
close(done)
|
||||||
|
})
|
||||||
|
|
||||||
|
It("uses ICSL after handshake", func(done Done) {
|
||||||
|
// session.lastNetworkActivityTime = time.Now().Add(-time.Minute)
|
||||||
|
*(*bool)(unsafe.Pointer(reflect.ValueOf(session.cryptoSetup).Elem().FieldByName("receivedForwardSecurePacket").UnsafeAddr())) = true
|
||||||
|
*(*crypto.AEAD)(unsafe.Pointer(reflect.ValueOf(session.cryptoSetup).Elem().FieldByName("forwardSecureAEAD").UnsafeAddr())) = &crypto.NullAEAD{}
|
||||||
|
session.connectionParametersManager.SetFromMap(map[handshake.Tag][]byte{
|
||||||
|
handshake.TagICSL: {0, 0, 0, 0},
|
||||||
|
})
|
||||||
|
session.packer.connectionParametersManager = session.connectionParametersManager
|
||||||
|
session.run() // Would normally not return
|
||||||
|
Expect(conn.written[0]).To(ContainSubstring("No recent network activity."))
|
||||||
|
close(done)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
It("errors when the SentPacketHandler has too many packets tracked", func() {
|
It("errors when the SentPacketHandler has too many packets tracked", func() {
|
||||||
|
|||||||
Reference in New Issue
Block a user