mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 03:38:42 -07:00
Move to crypto/rand for nonce generation (#3324)
Signed-off-by: Matthias Hanel <mh@synadia.com>
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"encoding/base64"
|
||||
)
|
||||
|
||||
@@ -41,6 +42,6 @@ func (s *Server) nonceRequired() bool {
|
||||
func (s *Server) generateNonce(n []byte) {
|
||||
var raw [nonceRawLen]byte
|
||||
data := raw[:]
|
||||
s.prand.Read(data)
|
||||
rand.Read(data)
|
||||
base64.RawURLEncoding.Encode(n, data)
|
||||
}
|
||||
|
||||
@@ -114,7 +114,6 @@ type Server struct {
|
||||
stats
|
||||
mu sync.RWMutex
|
||||
kp nkeys.KeyPair
|
||||
prand *rand.Rand
|
||||
info Info
|
||||
configFile string
|
||||
optsMu sync.RWMutex
|
||||
@@ -378,7 +377,6 @@ func NewServer(opts *Options) (*Server, error) {
|
||||
kp: kp,
|
||||
configFile: opts.ConfigFile,
|
||||
info: info,
|
||||
prand: rand.New(rand.NewSource(time.Now().UnixNano())),
|
||||
opts: opts,
|
||||
done: make(chan bool, 1),
|
||||
start: now,
|
||||
|
||||
Reference in New Issue
Block a user