Skip to content

Commit

Permalink
fixup! fix: fix seeder for randomizing speed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
phanyzewski committed Jul 13, 2023
1 parent 0cc31e0 commit d4cab46
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 7 deletions.
7 changes: 0 additions & 7 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ import (
"flag"
"fmt"
"io"
"math/rand"
"net"
"net/http"
"os"
"path/filepath"
"strconv"
"strings"
"sync"
"time"

"github.com/imup-io/client/util"
log "golang.org/x/exp/slog"
Expand All @@ -24,7 +22,6 @@ var ImUpAPIHost = "https://api.imup.io"

var (
setupFlags sync.Once
seedRandom sync.Once

allowlistedIPs *string
apiKey *string
Expand Down Expand Up @@ -166,10 +163,6 @@ func New() (Reloadable, error) {
// do not instantiate a new copy of config, use the package level global
cfg = &config{}

seedRandom.Do(func() {
rand.Seed(time.Now().UTC().UnixNano())
})

setupFlags.Do(func() {
allowlistedIPs = flag.String("allowlisted-ips", "", "comma separated list of CIDR strings to match against host IP that determines whether speed and connectivity testing will be run, default is allow all")
apiKey = flag.String("key", "", "an api key associated with an imup organization")
Expand Down
1 change: 1 addition & 0 deletions helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

// https://github.com/m-lab/ndt-server/blob/master/spec/ndt7-protocol.md#requirements-for-non-interactive-clients
func sleepTime() time.Duration {
rand := rand.New(rand.NewSource(int64(time.Now().Nanosecond())))
t := rand.ExpFloat64() * 21600
if t < 2160 {
t = 2160
Expand Down

0 comments on commit d4cab46

Please sign in to comment.