From ec76652f161d0116e85db57af95768639688accb Mon Sep 17 00:00:00 2001 From: Sean DuBois Date: Thu, 11 Jul 2024 22:33:04 -0400 Subject: [PATCH] Retransmit last flight when in finished When FSM is in finished and sees a handshake message re-send the last flight again. --- handshaker.go | 40 ---------------------------------------- handshaker_test.go | 4 ++-- 2 files changed, 2 insertions(+), 42 deletions(-) diff --git a/handshaker.go b/handshaker.go index ce3be24c3..a7125f8d9 100644 --- a/handshaker.go +++ b/handshaker.go @@ -327,51 +327,11 @@ func (s *handshakeFSM) wait(ctx context.Context, c flightConn) (handshakeState, } func (s *handshakeFSM) finish(ctx context.Context, c flightConn) (handshakeState, error) { - parse, errFlight := s.currentFlight.getFlightParser() - if errFlight != nil { - if alertErr := c.notify(ctx, alert.Fatal, alert.InternalError); alertErr != nil { - return handshakeErrored, alertErr - } - return handshakeErrored, errFlight - } - - retransmitTimer := time.NewTimer(s.retransmitInterval) select { case done := <-c.recvHandshake(): - nextFlight, alert, err := parse(ctx, c, s.state, s.cache, s.cfg) close(done) - s.retransmitInterval = s.cfg.initialRetransmitInterval - if alert != nil { - if alertErr := c.notify(ctx, alert.Level, alert.Description); alertErr != nil { - if err != nil { - err = alertErr - } - } - } - if err != nil { - return handshakeErrored, err - } - if nextFlight == 0 { - break - } - if nextFlight.isLastRecvFlight() && s.currentFlight == nextFlight { - return handshakeFinished, nil - } - <-retransmitTimer.C - - // RFC 4347 4.2.4.1 - if !s.cfg.disableRetransmitBackoff { - s.retransmitInterval *= 2 - } - if s.retransmitInterval > time.Second*60 { - s.retransmitInterval = time.Second * 60 - } - // Retransmit last flight return handshakeSending, nil - case <-ctx.Done(): - s.retransmitInterval = s.cfg.initialRetransmitInterval return handshakeErrored, ctx.Err() } - return handshakeFinished, nil } diff --git a/handshaker_test.go b/handshaker_test.go index b2bd4443d..b7d4f1bff 100644 --- a/handshaker_test.go +++ b/handshaker_test.go @@ -225,8 +225,8 @@ func TestHandshaker(t *testing.T) { t.Errorf("Client is not finished") } // there should be no `Finished` last retransmit from client - if cntClientFinishedLastRetransmit != 0 { - t.Errorf("Number of client finished last retransmit is wrong, expected: %d times, got: %d times", 0, cntClientFinishedLastRetransmit) + if cntClientFinishedLastRetransmit != 4 { + t.Errorf("Number of client finished last retransmit is wrong, expected: %d times, got: %d times", 4, cntClientFinishedLastRetransmit) } if cntServerFinished < 1 { t.Errorf("Number of server finished is wrong, expected: at least %d times, got: %d times", 1, cntServerFinished)