udp: clean up connection ID generation
This commit is contained in:
parent
89bc479a3b
commit
6dfdb7e192
1 changed files with 1 additions and 1 deletions
|
@ -25,7 +25,7 @@ const ttl = 2 * time.Minute
|
||||||
// forgery probability of approximately 1 in 4 billion.
|
// forgery probability of approximately 1 in 4 billion.
|
||||||
func NewConnectionID(ip net.IP, now time.Time, key string) []byte {
|
func NewConnectionID(ip net.IP, now time.Time, key string) []byte {
|
||||||
buf := make([]byte, 8)
|
buf := make([]byte, 8)
|
||||||
binary.BigEndian.PutUint32(buf, uint32(now.UTC().Unix()))
|
binary.BigEndian.PutUint32(buf, uint32(now.Unix()))
|
||||||
|
|
||||||
mac := hmac.New(sha256.New, []byte(key))
|
mac := hmac.New(sha256.New, []byte(key))
|
||||||
mac.Write(buf[:4])
|
mac.Write(buf[:4])
|
||||||
|
|
Loading…
Reference in a new issue