[management] Check groups when counting peers on networks list (#3284)

This commit is contained in:
Pascal Fischer 2025-02-06 13:36:57 +01:00 committed by GitHub
parent ca9aca9b19
commit cee4aeea9e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -7,6 +7,7 @@ import (
"net/http"
"github.com/gorilla/mux"
log "github.com/sirupsen/logrus"
s "github.com/netbirdio/netbird/management/server"
"github.com/netbirdio/netbird/management/server/groups"
@ -281,7 +282,12 @@ func (h *handler) collectIDsInNetwork(ctx context.Context, accountID, userID, ne
}
if len(router.PeerGroups) > 0 {
for _, groupID := range router.PeerGroups {
peerCounter += len(groups[groupID].Peers)
group, ok := groups[groupID]
if !ok {
log.WithContext(ctx).Warnf("group %s not found", groupID)
continue
}
peerCounter += len(group.Peers)
}
}
}