1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-12-18 08:26:45 +02:00
woodpecker/vendor/github.com/lucas-clemente/quic-go/internal/utils/connection_id.go

19 lines
396 B
Go
Raw Normal View History

2017-07-25 01:15:25 +02:00
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
}