0
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2024-12-30 22:34:15 -05:00
caddy/vendor/github.com/lucas-clemente/quic-go/internal/utils/connection_id.go
2017-07-27 16:11:56 -06:00

18 lines
396 B
Go

package utils
import (
"crypto/rand"
"encoding/binary"
"github.com/lucas-clemente/quic-go/protocol"
)
// GenerateConnectionID generates a connection ID using cryptographic random
func GenerateConnectionID() (protocol.ConnectionID, error) {
b := make([]byte, 8)
_, err := rand.Read(b)
if err != nil {
return 0, err
}
return protocol.ConnectionID(binary.LittleEndian.Uint64(b)), nil
}