2021-09-13 08:30:49 +00:00
|
|
|
package pxndscvm
|
|
|
|
|
|
|
|
import (
|
2021-09-25 03:26:57 +00:00
|
|
|
quiccmaffs "math/rand"
|
|
|
|
"time"
|
2021-09-13 08:30:49 +00:00
|
|
|
)
|
|
|
|
|
2021-09-18 10:38:22 +00:00
|
|
|
const (
|
|
|
|
grn = "\033[32m"
|
2021-09-24 19:07:56 +00:00
|
|
|
red = "\033[31m"
|
2021-09-18 10:38:22 +00:00
|
|
|
ylw = "\033[33m"
|
|
|
|
rst = "\033[0m"
|
|
|
|
)
|
|
|
|
|
2021-09-13 15:12:02 +00:00
|
|
|
// randStrChoice returns a random element from the given string slice
|
|
|
|
func randStrChoice(choices []string) string {
|
2021-09-13 08:30:49 +00:00
|
|
|
strlen := len(choices)
|
|
|
|
n := uint32(0)
|
|
|
|
if strlen > 0 {
|
2021-09-13 15:12:02 +00:00
|
|
|
n = getRandomUint32() % uint32(strlen)
|
2021-09-13 08:30:49 +00:00
|
|
|
}
|
|
|
|
return choices[n]
|
|
|
|
}
|
|
|
|
|
2021-09-13 15:12:02 +00:00
|
|
|
// getRandomUint32 retrieves a cryptographically sound random 32 bit unsigned little endian integer
|
|
|
|
func getRandomUint32() uint32 {
|
2021-09-25 03:26:57 +00:00
|
|
|
quiccmaffs.Seed(time.Now().UnixNano())
|
|
|
|
return quiccmaffs.Uint32()
|
|
|
|
}
|
|
|
|
|
|
|
|
func randSleep() {
|
|
|
|
quiccmaffs.Seed(time.Now().UnixNano())
|
|
|
|
time.Sleep(time.Duration(quiccmaffs.Intn(500)) * time.Millisecond)
|
2021-09-13 08:30:49 +00:00
|
|
|
}
|