Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Actually make sleepBeforeConnect() implement an exponential backoff #99

Merged
merged 1 commit into from
Oct 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions tapdance/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/hex"
"errors"
"fmt"
"math"
"os"
"strconv"
"time"
Expand Down Expand Up @@ -171,8 +172,9 @@ func WriteTlsLog(clientRandom, masterSecret []byte) error {

// How much time to sleep on trying to connect to decoys to prevent overwhelming them
func sleepBeforeConnect(attempt int) (waitTime <-chan time.Time) {
if attempt >= 6 { // return nil for first 6 attempts
waitTime = time.After(time.Second * 1)
if attempt >= 1 {
ms := math.Min(25*math.Pow(2, float64(attempt)), 15000)
waitTime = time.After(time.Duration(int(ms)) * time.Millisecond)
}
return
}
Expand Down