mirror of
https://github.com/jech/galene.git
synced 2024-11-26 02:25:58 +01:00
Draw recorder ids randomly.
This commit is contained in:
parent
7ce61a1100
commit
98245cbd24
1 changed files with 5 additions and 12 deletions
17
disk/disk.go
17
disk/disk.go
|
@ -1,11 +1,12 @@
|
||||||
package disk
|
package disk
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
crand "crypto/rand"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"encoding/hex"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -30,18 +31,10 @@ type Client struct {
|
||||||
closed bool
|
closed bool
|
||||||
}
|
}
|
||||||
|
|
||||||
var idCounter struct {
|
|
||||||
mu sync.Mutex
|
|
||||||
counter int
|
|
||||||
}
|
|
||||||
|
|
||||||
func newId() string {
|
func newId() string {
|
||||||
idCounter.mu.Lock()
|
b := make([]byte, 16)
|
||||||
defer idCounter.mu.Unlock()
|
crand.Read(b)
|
||||||
|
return hex.EncodeToString(b)
|
||||||
s := strconv.FormatInt(int64(idCounter.counter), 16)
|
|
||||||
idCounter.counter++
|
|
||||||
return s
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(g *group.Group) *Client {
|
func New(g *group.Group) *Client {
|
||||||
|
|
Loading…
Reference in a new issue