Skip to content

Commit

Permalink
fix linting mistakes
Browse files Browse the repository at this point in the history
  • Loading branch information
tsujamin committed Sep 7, 2022
1 parent 548551c commit 688cba7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
3 changes: 1 addition & 2 deletions acls_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (policy ACLPolicy) IsZero() bool {
return false
}

// Returns the list of autoApproving namespaces, groups or tags for a given IPPrefix
// Returns the list of autoApproving namespaces, groups or tags for a given IPPrefix.
func (autoApprovers *AutoApprovers) GetRouteApprovers(
prefix netip.Prefix,
) ([]string, error) {
Expand All @@ -121,7 +121,6 @@ func (autoApprovers *AutoApprovers) GetRouteApprovers(

for autoApprovedPrefix, autoApproverAliases := range autoApprovers.Routes {
autoApprovedPrefix, err := netip.ParsePrefix(autoApprovedPrefix)

if err != nil {
return nil, err
}
Expand Down
15 changes: 7 additions & 8 deletions machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -930,17 +930,16 @@ func (h *Headscale) EnableRoutes(machine *Machine, routeStrs ...string) error {
return nil
}

// Enabled any routes advertised by a machine that match the ACL autoApprovers policy
func (h *Headscale) EnableAutoApprovedRoutes(machine *Machine) error {
// Enabled any routes advertised by a machine that match the ACL autoApprovers policy.
func (h *Headscale) EnableAutoApprovedRoutes(machine *Machine) {
if len(machine.IPAddresses) == 0 {
return nil // This machine has no IPAddresses, so can't possibly match any autoApprovers ACLs
return // This machine has no IPAddresses, so can't possibly match any autoApprovers ACLs
}

approvedRoutes := make([]netip.Prefix, 0, len(machine.HostInfo.RoutableIPs))
thisMachine := []Machine{*machine}

for _, advertisedRoute := range machine.HostInfo.RoutableIPs {

if contains(machine.EnabledRoutes, advertisedRoute) {
continue // Skip routes that are already enabled for the node
}
Expand All @@ -953,7 +952,8 @@ func (h *Headscale) EnableAutoApprovedRoutes(machine *Machine) error {
Str("advertisedRoute", advertisedRoute.String()).
Uint64("machineId", machine.ID).
Msg("Failed to resolve autoApprovers for advertised route")
return err

return
}

for _, approvedAlias := range routeApprovers {
Expand All @@ -965,7 +965,8 @@ func (h *Headscale) EnableAutoApprovedRoutes(machine *Machine) error {
log.Err(err).
Str("alias", approvedAlias).
Msg("Failed to expand alias when processing autoApprovers policy")
return err

return
}

// approvedIPs should contain all of machine's IPs if it matches the rule, so check for first
Expand All @@ -985,8 +986,6 @@ func (h *Headscale) EnableAutoApprovedRoutes(machine *Machine) error {
machine.EnabledRoutes = append(machine.EnabledRoutes, approvedRoute)
}
}

return nil
}

func (machine *Machine) RoutesToProto() *v1.Routes {
Expand Down

0 comments on commit 688cba7

Please sign in to comment.