From 02fae654a0281a196fa67149d46b9a721b2b36a7 Mon Sep 17 00:00:00 2001 From: Eric Wustrow Date: Thu, 29 Sep 2022 13:10:39 -0600 Subject: [PATCH] Actually make sleepBeforeConnect() implement an exponential backoff --- tapdance/common.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tapdance/common.go b/tapdance/common.go index d3128f51..6a0327d9 100644 --- a/tapdance/common.go +++ b/tapdance/common.go @@ -5,6 +5,7 @@ import ( "encoding/hex" "errors" "fmt" + "math" "os" "strconv" "time" @@ -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 }