Skip to content

Commit

Permalink
Use crypto/rand in randRange and downgrade go version
Browse files Browse the repository at this point in the history
  • Loading branch information
theodorsm committed Dec 8, 2024
1 parent 8c7b40c commit 87cc02d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/theodorsm/covert-dtls

go 1.22
go 1.21

require (
github.com/google/gopacket v1.1.19
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down
13 changes: 11 additions & 2 deletions pkg/randomize/util.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
package randomize

import (
"math/rand/v2"
"crypto/rand"
"math/big"
)

func randRange(min, max int) int {
return rand.IntN(max-min+1) + min
bigRandomNumber, err := rand.Int(rand.Reader, big.NewInt(int64(max+1)))
if err != nil {
panic(err)
}
randomNumber := int(bigRandomNumber.Int64())
if randomNumber < min {
return min
}
return randomNumber
}

var ALPNS = []string{"http/1.0", "http/1.1", "h2c", "h2", "h3", "stun.turn", "webrtc", "c-webrtc", "ftp", "pop3", "imap", "mqtt", "smb", "irc", "sip/2"}
Expand Down

0 comments on commit 87cc02d

Please sign in to comment.