Merge pull request #1959 from lucas-clemente/optimize-crypto-packet-sending

optimize sending of crypto packets
This commit is contained in:
Marten Seemann
2019-06-29 00:03:12 +08:00
committed by GitHub
3 changed files with 109 additions and 51 deletions

View File

@@ -552,6 +552,9 @@ func (h *cryptoSetup) GetInitialSealer() (LongHeaderSealer, error) {
h.mutex.Lock()
defer h.mutex.Unlock()
if h.initialSealer == nil {
return nil, ErrKeysDropped
}
return h.initialSealer, nil
}
@@ -560,6 +563,9 @@ func (h *cryptoSetup) GetHandshakeSealer() (LongHeaderSealer, error) {
defer h.mutex.Unlock()
if h.handshakeSealer == nil {
if h.initialSealer == nil {
return nil, ErrKeysDropped
}
return nil, errors.New("CryptoSetup: no sealer with encryption level Handshake")
}
return h.handshakeSealer, nil