Skip to content

Commit

Permalink
Replace a horrible random construct with a less horrible one.
Browse files Browse the repository at this point in the history
Rand is randomly initalized on startup so no need to reshuffle it.
Surprised this code did not xor the PID into the seed for more profit
  • Loading branch information
cjeker committed Aug 6, 2024
1 parent bf5793c commit 47d57cc
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions lib/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,17 @@ import (
"flag"
"fmt"
"io"
"math"
"math/rand"
"net"
"net/netip"
"sync"
"time"

"golang.org/x/crypto/ssh"
)

func GenerateSessionId() uint16 {
var sessid uint16
r := rand.New(rand.NewSource(time.Now().UTC().Unix()))
sessid = uint16(r.Uint32())
return sessid
return uint16(rand.Intn(math.MaxUint16 + 1))
}

type RTRServerEventHandler interface {
Expand Down

0 comments on commit 47d57cc

Please sign in to comment.