Revert defunct dev branch stuff

This commit is contained in:
kayos@tcp.direct 2022-09-28 00:04:16 -07:00
parent 68d7cd9ecc
commit 358021fb40
Signed by: kayos
GPG Key ID: 4B841471B4BEE979
3 changed files with 11 additions and 28 deletions

View File

@ -23,14 +23,6 @@ func RandomStrChoice(choice []string) string {
return ""
}
// GetRandomSliceValue returns a random item from an input slice of strings.
func GetRandomSliceValue(choice ...any) any {
if len(choice) > 0 {
return choice[RNGUint32()%uint32(len(choice))]
}
return nil
}
// GetCryptoSeed returns a random int64 derived from crypto/rand.
// This can be used as a seed for the math/rand package.
func GetCryptoSeed() int64 {

View File

@ -84,27 +84,15 @@ func Test_RandStr_Entropy(t *testing.T) {
t.Logf("[ENTROPY] final score (lower is better): %d (RandStr)", totalScore)
}
func sliceTest[T comparable](t *testing.T, do func(...T) T) {
var slice []T
for n := 0; n != 500; n++ {
var item interface{} = RandStr(555)
slice = append(slice, item)
}
check(do(slice), do(slice), t)
}
func Test_RandomSliceValue(t *testing.T) {
func Test_RandomStrChoice(t *testing.T) {
if RandomStrChoice([]string{}) != "" {
t.Fatalf("RandomStrChoice returned a value when given an empty slice")
}
sliceTest(t, GetRandomSliceValue)
}
func Test_RandomStrChoice(t *testing.T) {
if GetRandomSliceValue([]interface{}{}) != nil {
t.Fatalf("GetRandomSliceValue returned a value when given an empty slice")
var slice []string
for n := 0; n != 500; n++ {
slice = append(slice, RandStr(555))
}
sliceTest(t, RandomStrChoice)
check(RandomStrChoice(slice), RandomStrChoice(slice), t)
}
func Test_RNGUint32(t *testing.T) {

View File

@ -11,9 +11,11 @@ IterateNetRange will ingest:
- or a string to be parsed as either of the above options
- examples: (192.168.69.0/24) (192.168.69.0-192.168.69.254)
- valid subnet string example: 192.168.69.0/24
then it returns a channel that will stream all the individual netaddr.IP types within the given range or prefix.
- valid range string example: 192.168.69.0-192.168.69.254
it then returns a channel that will stream all the individual netaddr.IP types within the given range or prefix.
if the input is invalid this function will return nil.
*/
func IterateNetRange(ips interface{}) chan ipa.IP {
@ -39,13 +41,14 @@ func IterateNetRange(ips interface{}) chan ipa.IP {
return nil
}
ch := make(chan ipa.IP)
ch := make(chan ipa.IP, 254)
go func(ret chan ipa.IP) {
for head := addrs.From(); head != addrs.To(); head = head.Next() {
if !head.IsUnspecified() {
ret <- head
}
}
close(ret)
}(ch)
return ch
}