tUse crypto/rand in dam-client to select random directories. - tordam - A library for peer discovery inside the Tor network HTML git clone https://git.parazyd.org/tordam DIR Log DIR Files DIR Refs DIR README DIR LICENSE --- DIR commit f2e497aad3f96a3275a2873e6a55d964b63cbcf3 DIR parent 39b928efaa30cc577a7ed8f0fe8605c77023d857 HTML Author: parazyd <parazyd@dyne.org> Date: Mon, 12 Mar 2018 11:17:19 +0100 Use crypto/rand in dam-client to select random directories. Diffstat: M cmd/dam-client/main.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) --- DIR diff --git a/cmd/dam-client/main.go b/cmd/dam-client/main.go t@@ -24,12 +24,13 @@ import ( "bufio" "bytes" "compress/gzip" + "crypto/rand" "crypto/rsa" "encoding/base64" "encoding/json" "io/ioutil" "log" - "math/rand" + "math/big" "os" "os/exec" "strconv" t@@ -193,10 +194,9 @@ func fetchDirlist(locations []string) ([]string, error) { log.Println("Found enough directories. Picking out 6 random ones.") // Pick out 6 random directories from the retrieved list. for k := 0; k <= 5; k++ { - rand.Seed(time.Now().Unix()) - n := rand.Int() % len(dirSlice) - dirlist = append(dirlist, dirSlice[n]) - dirSlice[n] = dirSlice[len(dirSlice)-1] + n, _ := rand.Int(rand.Reader, big.NewInt(int64(len(dirSlice)))) + dirlist = append(dirlist, dirSlice[n.Int64()]) + dirSlice[n.Int64()] = dirSlice[len(dirSlice)-1] dirSlice = dirSlice[:len(dirSlice)-1] } }