mirror of
https://github.com/FiloSottile/age.git
synced 2025-12-23 05:25:14 +00:00
plugin: avoid using deprecated math/rand.Read
This commit is contained in:
committed by
Filippo Valsorda
parent
96b6476140
commit
83bab2ae6a
@@ -8,9 +8,10 @@ package plugin
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"crypto/rand"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"math/rand"
|
mathrand "math/rand/v2"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -468,15 +469,15 @@ func writeStanzaWithBody(conn io.Writer, t string, body []byte) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func writeGrease(conn io.Writer) (sent bool, err error) {
|
func writeGrease(conn io.Writer) (sent bool, err error) {
|
||||||
if rand.Intn(3) == 0 {
|
if mathrand.IntN(3) == 0 {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
s := &format.Stanza{Type: fmt.Sprintf("grease-%x", rand.Int())}
|
s := &format.Stanza{Type: fmt.Sprintf("grease-%x", mathrand.Int())}
|
||||||
for i := 0; i < rand.Intn(3); i++ {
|
for i := 0; i < mathrand.IntN(3); i++ {
|
||||||
s.Args = append(s.Args, fmt.Sprintf("%d", rand.Intn(100)))
|
s.Args = append(s.Args, fmt.Sprintf("%d", mathrand.IntN(100)))
|
||||||
}
|
}
|
||||||
if rand.Intn(2) == 0 {
|
if mathrand.IntN(2) == 0 {
|
||||||
s.Body = make([]byte, rand.Intn(100))
|
s.Body = make([]byte, mathrand.IntN(100))
|
||||||
rand.Read(s.Body)
|
rand.Read(s.Body)
|
||||||
}
|
}
|
||||||
return true, s.Marshal(conn)
|
return true, s.Marshal(conn)
|
||||||
|
|||||||
Reference in New Issue
Block a user