mirror of
https://github.com/netbirdio/netbird.git
synced 2024-11-22 16:13:31 +01:00
chore: setup key upper case
This commit is contained in:
parent
1dfa99d07c
commit
c68d9dff4a
@ -6,6 +6,7 @@ import (
|
|||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
"google.golang.org/grpc/status"
|
"google.golang.org/grpc/status"
|
||||||
"net"
|
"net"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -175,7 +176,7 @@ func (manager *AccountManager) AddPeer(setupKey string, peerKey string) (*Peer,
|
|||||||
// Empty setup key, create a new account for it.
|
// Empty setup key, create a new account for it.
|
||||||
account, sk = newAccount()
|
account, sk = newAccount()
|
||||||
} else {
|
} else {
|
||||||
sk = &SetupKey{Key: setupKey}
|
sk = &SetupKey{Key: strings.ToUpper(setupKey)}
|
||||||
account, err = manager.Store.GetAccountBySetupKey(sk.Key)
|
account, err = manager.Store.GetAccountBySetupKey(sk.Key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, status.Errorf(codes.NotFound, "unknown setupKey %s", setupKey)
|
return nil, status.Errorf(codes.NotFound, "unknown setupKey %s", setupKey)
|
||||||
@ -211,7 +212,7 @@ func newAccountWithId(accountId string) (*Account, *SetupKey) {
|
|||||||
|
|
||||||
log.Debugf("creating new account")
|
log.Debugf("creating new account")
|
||||||
|
|
||||||
setupKeyId := uuid.New().String()
|
setupKeyId := strings.ToUpper(uuid.New().String())
|
||||||
setupKeys := make(map[string]*SetupKey)
|
setupKeys := make(map[string]*SetupKey)
|
||||||
setupKey := &SetupKey{Key: setupKeyId}
|
setupKey := &SetupKey{Key: setupKeyId}
|
||||||
setupKeys[setupKeyId] = setupKey
|
setupKeys[setupKeyId] = setupKey
|
||||||
|
@ -67,7 +67,7 @@ func restore(file string) (*FileStore, error) {
|
|||||||
store.PeerKeyId2AccountId = make(map[string]string)
|
store.PeerKeyId2AccountId = make(map[string]string)
|
||||||
for accountId, account := range store.Accounts {
|
for accountId, account := range store.Accounts {
|
||||||
for setupKeyId := range account.SetupKeys {
|
for setupKeyId := range account.SetupKeys {
|
||||||
store.SetupKeyId2AccountId[strings.ToLower(setupKeyId)] = accountId
|
store.SetupKeyId2AccountId[strings.ToUpper(setupKeyId)] = accountId
|
||||||
}
|
}
|
||||||
for _, peer := range account.Peers {
|
for _, peer := range account.Peers {
|
||||||
store.PeerKeyId2AccountId[peer.Key] = accountId
|
store.PeerKeyId2AccountId[peer.Key] = accountId
|
||||||
@ -133,7 +133,7 @@ func (s *FileStore) SaveAccount(account *Account) error {
|
|||||||
|
|
||||||
func (s *FileStore) GetAccountBySetupKey(setupKey string) (*Account, error) {
|
func (s *FileStore) GetAccountBySetupKey(setupKey string) (*Account, error) {
|
||||||
|
|
||||||
accountId, accountIdFound := s.SetupKeyId2AccountId[strings.ToLower(setupKey)]
|
accountId, accountIdFound := s.SetupKeyId2AccountId[strings.ToUpper(setupKey)]
|
||||||
if !accountIdFound {
|
if !accountIdFound {
|
||||||
return nil, status.Errorf(codes.NotFound, "provided setup key doesn't exists")
|
return nil, status.Errorf(codes.NotFound, "provided setup key doesn't exists")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user