lib/connections: Add QUIC protocol support (fixes #5377) (#5737)

This commit is contained in:
Audrius Butkevicius
2019-05-29 08:56:40 +01:00
committed by Jakob Borg
parent d8fa61e27c
commit e714df013f
32 changed files with 1290 additions and 128 deletions

View File

@@ -14,6 +14,7 @@ import (
"encoding/binary"
"io"
mathRand "math/rand"
"reflect"
)
// Reader is the standard crypto/rand.Reader, re-exported for convenience
@@ -73,3 +74,14 @@ func SeedFromBytes(bs []byte) int64 {
// uint64s and XOR them together.
return int64(binary.BigEndian.Uint64(s[0:]) ^ binary.BigEndian.Uint64(s[8:]))
}
// Shuffle the order of elements
func Shuffle(slice interface{}) {
rv := reflect.ValueOf(slice)
swap := reflect.Swapper(slice)
length := rv.Len()
if length < 2 {
return
}
defaultSecureRand.Shuffle(length, swap)
}