Skip to content

Commit 7f1bcf5

Browse files
committed
plugin: avoid using deprecated math/rand.Read
1 parent e1f8cd6 commit 7f1bcf5

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

plugin/client.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ package plugin
88

99
import (
1010
"bufio"
11+
"crypto/rand"
1112
"fmt"
1213
"io"
13-
"math/rand"
14+
mathrand "math/rand/v2"
1415
"os"
1516
"path/filepath"
1617
"strconv"
@@ -468,15 +469,15 @@ func writeStanzaWithBody(conn io.Writer, t string, body []byte) error {
468469
}
469470

470471
func writeGrease(conn io.Writer) (sent bool, err error) {
471-
if rand.Intn(3) == 0 {
472+
if mathrand.IntN(3) == 0 {
472473
return false, nil
473474
}
474-
s := &format.Stanza{Type: fmt.Sprintf("grease-%x", rand.Int())}
475-
for i := 0; i < rand.Intn(3); i++ {
476-
s.Args = append(s.Args, fmt.Sprintf("%d", rand.Intn(100)))
475+
s := &format.Stanza{Type: fmt.Sprintf("grease-%x", mathrand.Int())}
476+
for i := 0; i < mathrand.IntN(3); i++ {
477+
s.Args = append(s.Args, fmt.Sprintf("%d", mathrand.IntN(100)))
477478
}
478-
if rand.Intn(2) == 0 {
479-
s.Body = make([]byte, rand.Intn(100))
479+
if mathrand.IntN(2) == 0 {
480+
s.Body = make([]byte, mathrand.IntN(100))
480481
rand.Read(s.Body)
481482
}
482483
return true, s.Marshal(conn)

0 commit comments

Comments
 (0)