mirror of
https://github.com/netbirdio/netbird.git
synced 2026-09-15 11:19:08 +02:00
Address CodeRabbit review on embedded VNC PR
This commit is contained in:
@@ -243,7 +243,7 @@ func (c *NetworkMapComponents) resolveRuleEndpoint(
|
||||
postureChecks []string,
|
||||
) ([]*nbpeer.Peer, bool) {
|
||||
if resource.Type == ResourceTypePeer && resource.ID != "" {
|
||||
return c.getPeerFromResource(resource, peerID)
|
||||
return c.getPeerFromResource(resource, peerID, postureChecks)
|
||||
}
|
||||
return c.getAllPeersFromGroups(groups, peerID, postureChecks)
|
||||
}
|
||||
@@ -385,8 +385,11 @@ func (c *NetworkMapComponents) getUniquePeerIDsFromGroupsIDs(groups []string) []
|
||||
return ids
|
||||
}
|
||||
|
||||
func (c *NetworkMapComponents) getPeerFromResource(resource Resource, peerID string) ([]*nbpeer.Peer, bool) {
|
||||
func (c *NetworkMapComponents) getPeerFromResource(resource Resource, peerID string, postureChecks []string) ([]*nbpeer.Peer, bool) {
|
||||
if resource.ID == peerID {
|
||||
if len(postureChecks) > 0 && !c.ValidatePostureChecksOnPeer(peerID, postureChecks) {
|
||||
return []*nbpeer.Peer{}, false
|
||||
}
|
||||
return []*nbpeer.Peer{}, true
|
||||
}
|
||||
|
||||
@@ -394,6 +397,9 @@ func (c *NetworkMapComponents) getPeerFromResource(resource Resource, peerID str
|
||||
if peerInfo == nil {
|
||||
return []*nbpeer.Peer{}, false
|
||||
}
|
||||
if len(postureChecks) > 0 && !c.ValidatePostureChecksOnPeer(resource.ID, postureChecks) {
|
||||
return []*nbpeer.Peer{}, false
|
||||
}
|
||||
|
||||
return []*nbpeer.Peer{peerInfo}, false
|
||||
}
|
||||
|
||||
@@ -59,9 +59,10 @@ func applyResolvedRuleToState(
|
||||
) {
|
||||
emitRuleDirections(rule, sourcePeers, destPeers, peerInSources, peerInDestinations, generateResources)
|
||||
|
||||
receivingPeer := peerInDestinations || (rule.Bidirectional && peerInSources)
|
||||
switch {
|
||||
case rule.Protocol == PolicyRuleProtocolNetbirdSSH:
|
||||
if !peerInDestinations {
|
||||
if !receivingPeer {
|
||||
return
|
||||
}
|
||||
state.sshEnabled = true
|
||||
@@ -69,7 +70,7 @@ func applyResolvedRuleToState(
|
||||
case rule.Protocol == PolicyRuleProtocolNetbirdVNC:
|
||||
cb.handleVNCRule(rule, peerInSources, peerInDestinations, state)
|
||||
case policyRuleImpliesLegacySSH(rule) && targetPeerSSHEnabled:
|
||||
if !peerInDestinations {
|
||||
if !receivingPeer {
|
||||
return
|
||||
}
|
||||
state.sshEnabled = true
|
||||
|
||||
Reference in New Issue
Block a user