minor fixes on diffs

This commit is contained in:
crn4
2026-01-21 17:12:34 +01:00
parent ad025e452b
commit b32cf57ed1
2 changed files with 19 additions and 3 deletions

View File

@@ -42,6 +42,7 @@ func (a *Account) GetPeerNetworkMapComponents(
RoutersMap: make(map[string]map[string]*routerTypes.NetworkRouter),
NetworkResources: make([]*resourceTypes.NetworkResource, 0),
PostureFailedPeers: make(map[string]map[string]struct{}, len(a.PostureChecks)),
RouterPeers: make(map[string]*nbpeer.Peer),
}
components.AccountSettings = &AccountSettingsInfo{
@@ -161,9 +162,12 @@ func (a *Account) GetPeerNetworkMapComponents(
components.RoutersMap[resource.NetworkID] = networkRoutingPeers
for peerIDKey := range networkRoutingPeers {
if _, exists := components.Peers[peerIDKey]; !exists {
if _, validated := validatedPeersMap[peerIDKey]; validated {
if p := a.Peers[peerIDKey]; p != nil {
if p := a.Peers[peerIDKey]; p != nil {
if _, exists := components.RouterPeers[peerIDKey]; !exists {
components.RouterPeers[peerIDKey] = p
}
if _, exists := components.Peers[peerIDKey]; !exists {
if _, validated := validatedPeersMap[peerIDKey]; validated {
components.Peers[peerIDKey] = p
}
}

View File

@@ -41,6 +41,8 @@ type NetworkMapComponents struct {
GroupIDToUserIDs map[string][]string
AllowedUserIDs map[string]struct{}
PostureFailedPeers map[string]map[string]struct{}
RouterPeers map[string]*nbpeer.Peer
}
type AccountSettingsInfo struct {
@@ -54,6 +56,10 @@ func (c *NetworkMapComponents) GetPeerInfo(peerID string) *nbpeer.Peer {
return c.Peers[peerID]
}
func (c *NetworkMapComponents) GetRouterPeerInfo(peerID string) *nbpeer.Peer {
return c.RouterPeers[peerID]
}
func (c *NetworkMapComponents) GetGroupInfo(groupID string) *Group {
return c.Groups[groupID]
}
@@ -479,6 +485,9 @@ func (calc *NetworkMapCalculator) getRoutesToSync(ctx context.Context, peerID st
func (calc *NetworkMapCalculator) getRoutingPeerRoutes(ctx context.Context, peerID string) (enabledRoutes []*route.Route, disabledRoutes []*route.Route) {
peerInfo := calc.components.GetPeerInfo(peerID)
if peerInfo == nil {
peerInfo = calc.components.GetRouterPeerInfo(peerID)
}
if peerInfo == nil {
return enabledRoutes, disabledRoutes
}
@@ -960,6 +969,9 @@ func (calc *NetworkMapCalculator) addNetworksRoutingPeers(
for p := range missingPeers {
peerInfo := calc.components.GetPeerInfo(p)
if peerInfo == nil {
peerInfo = calc.components.GetRouterPeerInfo(p)
}
if peerInfo != nil {
peersToConnect = append(peersToConnect, peerInfo)
}