From 98245cbd24366aa8f3e6ebc98394b8303c332a80 Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Fri, 18 Sep 2020 10:23:53 +0200 Subject: [PATCH] Draw recorder ids randomly. --- disk/disk.go | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/disk/disk.go b/disk/disk.go index 1173713..fd9328e 100644 --- a/disk/disk.go +++ b/disk/disk.go @@ -1,11 +1,12 @@ package disk import ( + crand "crypto/rand" "errors" "fmt" "os" "path/filepath" - "strconv" + "encoding/hex" "sync" "time" @@ -30,18 +31,10 @@ type Client struct { closed bool } -var idCounter struct { - mu sync.Mutex - counter int -} - func newId() string { - idCounter.mu.Lock() - defer idCounter.mu.Unlock() - - s := strconv.FormatInt(int64(idCounter.counter), 16) - idCounter.counter++ - return s + b := make([]byte, 16) + crand.Read(b) + return hex.EncodeToString(b) } func New(g *group.Group) *Client {