mirror of
https://github.com/netbirdio/netbird.git
synced 2025-05-29 14:22:41 +02:00
Skip network map check if not regular user (#2402)
when getting all peers we don't need to calculate network map when not a regular user
This commit is contained in:
parent
855fba8fac
commit
54d896846b
@ -65,12 +65,14 @@ func (am *DefaultAccountManager) GetPeers(ctx context.Context, accountID, userID
|
|||||||
peers := make([]*nbpeer.Peer, 0)
|
peers := make([]*nbpeer.Peer, 0)
|
||||||
peersMap := make(map[string]*nbpeer.Peer)
|
peersMap := make(map[string]*nbpeer.Peer)
|
||||||
|
|
||||||
if !user.HasAdminPower() && !user.IsServiceUser && account.Settings.RegularUsersViewBlocked {
|
regularUser := !user.HasAdminPower() && !user.IsServiceUser
|
||||||
|
|
||||||
|
if regularUser && account.Settings.RegularUsersViewBlocked {
|
||||||
return peers, nil
|
return peers, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, peer := range account.Peers {
|
for _, peer := range account.Peers {
|
||||||
if !(user.HasAdminPower() || user.IsServiceUser) && user.Id != peer.UserID {
|
if regularUser && user.Id != peer.UserID {
|
||||||
// only display peers that belong to the current user if the current user is not an admin
|
// only display peers that belong to the current user if the current user is not an admin
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -79,6 +81,10 @@ func (am *DefaultAccountManager) GetPeers(ctx context.Context, accountID, userID
|
|||||||
peersMap[peer.ID] = p
|
peersMap[peer.ID] = p
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !regularUser {
|
||||||
|
return peers, nil
|
||||||
|
}
|
||||||
|
|
||||||
// fetch all the peers that have access to the user's peers
|
// fetch all the peers that have access to the user's peers
|
||||||
for _, peer := range peers {
|
for _, peer := range peers {
|
||||||
aclPeers, _ := account.getPeerConnectionResources(ctx, peer.ID, approvedPeersMap)
|
aclPeers, _ := account.getPeerConnectionResources(ctx, peer.ID, approvedPeersMap)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user