Skip to content

Commit

Permalink
feat: update math/rand to math/rand/v2
Browse files Browse the repository at this point in the history
  • Loading branch information
ef0xa committed Jun 27, 2024
1 parent ad5f1f7 commit fd4dbd4
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions cmd/croc/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ package croc

import (
"fmt"
"math/rand"
"math/rand/v2"
"strconv"
"strings"
"time"

"github.com/schollz/croc/v9/src/models"
"github.com/schollz/croc/v9/src/utils"
Expand All @@ -32,9 +31,6 @@ var SendCmd = &cobra.Command{
Short: "send file(s), or folder",
Long: "send file(s), or folder to pod or any computer",
Run: func(cmd *cobra.Command, args []string) {

rand.Seed(time.Now().UnixNano())

// Make a GET request to the URL
relays, err := GetRelays()
if err != nil {
Expand All @@ -43,9 +39,9 @@ var SendCmd = &cobra.Command{
return
}

randIndex := rand.IntN(len(relays))
// Choose a random relay from the array
randomIndex := rand.Intn(len(relays))
relay := relays[randomIndex]
relay := relays[randIndex]

crocOptions := Options{
Curve: "p256",
Expand Down Expand Up @@ -78,7 +74,7 @@ var SendCmd = &cobra.Command{
crocOptions.SharedSecret = utils.GetRandomName()
}

crocOptions.SharedSecret = crocOptions.SharedSecret + "-" + strconv.Itoa(randomIndex)
crocOptions.SharedSecret = crocOptions.SharedSecret + "-" + strconv.Itoa(randIndex)

minimalFileInfos, emptyFoldersToTransfer, totalNumberFolders, err := GetFilesInfo(fnames, crocOptions.ZipFolder)
if err != nil {
Expand Down

0 comments on commit fd4dbd4

Please sign in to comment.