mirror of
https://github.com/netbirdio/netbird.git
synced 2024-12-15 19:31:06 +01:00
25 lines
393 B
Go
25 lines
393 B
Go
package hmac
|
|
|
|
import (
|
|
"sync"
|
|
)
|
|
|
|
// Store is a simple in-memory store for token
|
|
// With this can update the token in thread safe way
|
|
type Store struct {
|
|
mu sync.Mutex
|
|
token Token
|
|
}
|
|
|
|
func (a *Store) UpdateToken(token Token) {
|
|
a.mu.Lock()
|
|
defer a.mu.Unlock()
|
|
a.token = token
|
|
}
|
|
|
|
func (a *Store) Token() ([]byte, error) {
|
|
a.mu.Lock()
|
|
defer a.mu.Unlock()
|
|
return marshalToken(a.token)
|
|
}
|