forked from quic-go/quic-go
Merge pull request #2358 from lucas-clemente/drop-0rtt-keys
drop 0-RTT read keys after 3 PTO
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"sync"
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/lucas-clemente/quic-go/internal/congestion"
|
"github.com/lucas-clemente/quic-go/internal/congestion"
|
||||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||||
@@ -95,6 +96,8 @@ type cryptoSetup struct {
|
|||||||
|
|
||||||
mutex sync.Mutex // protects all members below
|
mutex sync.Mutex // protects all members below
|
||||||
|
|
||||||
|
handshakeCompleteTime time.Time
|
||||||
|
|
||||||
readEncLevel protocol.EncryptionLevel
|
readEncLevel protocol.EncryptionLevel
|
||||||
writeEncLevel protocol.EncryptionLevel
|
writeEncLevel protocol.EncryptionLevel
|
||||||
|
|
||||||
@@ -244,6 +247,9 @@ func (h *cryptoSetup) RunHandshake() {
|
|||||||
|
|
||||||
select {
|
select {
|
||||||
case <-handshakeComplete: // return when the handshake is done
|
case <-handshakeComplete: // return when the handshake is done
|
||||||
|
h.mutex.Lock()
|
||||||
|
h.handshakeCompleteTime = time.Now()
|
||||||
|
h.mutex.Unlock()
|
||||||
h.runner.OnHandshakeComplete()
|
h.runner.OnHandshakeComplete()
|
||||||
case <-h.closeChan:
|
case <-h.closeChan:
|
||||||
close(h.messageChan)
|
close(h.messageChan)
|
||||||
@@ -764,6 +770,11 @@ func (h *cryptoSetup) Get1RTTOpener() (ShortHeaderOpener, error) {
|
|||||||
h.mutex.Lock()
|
h.mutex.Lock()
|
||||||
defer h.mutex.Unlock()
|
defer h.mutex.Unlock()
|
||||||
|
|
||||||
|
if h.zeroRTTOpener != nil && time.Since(h.handshakeCompleteTime) > 3*h.rttStats.PTO(true) {
|
||||||
|
h.zeroRTTOpener = nil
|
||||||
|
h.logger.Debugf("Dropping 0-RTT keys.")
|
||||||
|
}
|
||||||
|
|
||||||
if !h.has1RTTOpener {
|
if !h.has1RTTOpener {
|
||||||
return nil, ErrKeysNotYetAvailable
|
return nil, ErrKeysNotYetAvailable
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user