mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-30 13:35:23 +00:00
fix linting mistakes
This commit is contained in:
parent
548551c6ae
commit
688cba7292
@ -109,7 +109,7 @@ func (policy ACLPolicy) IsZero() bool {
|
|||||||
return false
|
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(
|
func (autoApprovers *AutoApprovers) GetRouteApprovers(
|
||||||
prefix netip.Prefix,
|
prefix netip.Prefix,
|
||||||
) ([]string, error) {
|
) ([]string, error) {
|
||||||
@ -121,7 +121,6 @@ func (autoApprovers *AutoApprovers) GetRouteApprovers(
|
|||||||
|
|
||||||
for autoApprovedPrefix, autoApproverAliases := range autoApprovers.Routes {
|
for autoApprovedPrefix, autoApproverAliases := range autoApprovers.Routes {
|
||||||
autoApprovedPrefix, err := netip.ParsePrefix(autoApprovedPrefix)
|
autoApprovedPrefix, err := netip.ParsePrefix(autoApprovedPrefix)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
15
machine.go
15
machine.go
@ -930,17 +930,16 @@ func (h *Headscale) EnableRoutes(machine *Machine, routeStrs ...string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enabled any routes advertised by a machine that match the ACL autoApprovers policy
|
// Enabled any routes advertised by a machine that match the ACL autoApprovers policy.
|
||||||
func (h *Headscale) EnableAutoApprovedRoutes(machine *Machine) error {
|
func (h *Headscale) EnableAutoApprovedRoutes(machine *Machine) {
|
||||||
if len(machine.IPAddresses) == 0 {
|
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))
|
approvedRoutes := make([]netip.Prefix, 0, len(machine.HostInfo.RoutableIPs))
|
||||||
thisMachine := []Machine{*machine}
|
thisMachine := []Machine{*machine}
|
||||||
|
|
||||||
for _, advertisedRoute := range machine.HostInfo.RoutableIPs {
|
for _, advertisedRoute := range machine.HostInfo.RoutableIPs {
|
||||||
|
|
||||||
if contains(machine.EnabledRoutes, advertisedRoute) {
|
if contains(machine.EnabledRoutes, advertisedRoute) {
|
||||||
continue // Skip routes that are already enabled for the node
|
continue // Skip routes that are already enabled for the node
|
||||||
}
|
}
|
||||||
@ -953,7 +952,8 @@ func (h *Headscale) EnableAutoApprovedRoutes(machine *Machine) error {
|
|||||||
Str("advertisedRoute", advertisedRoute.String()).
|
Str("advertisedRoute", advertisedRoute.String()).
|
||||||
Uint64("machineId", machine.ID).
|
Uint64("machineId", machine.ID).
|
||||||
Msg("Failed to resolve autoApprovers for advertised route")
|
Msg("Failed to resolve autoApprovers for advertised route")
|
||||||
return err
|
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, approvedAlias := range routeApprovers {
|
for _, approvedAlias := range routeApprovers {
|
||||||
@ -965,7 +965,8 @@ func (h *Headscale) EnableAutoApprovedRoutes(machine *Machine) error {
|
|||||||
log.Err(err).
|
log.Err(err).
|
||||||
Str("alias", approvedAlias).
|
Str("alias", approvedAlias).
|
||||||
Msg("Failed to expand alias when processing autoApprovers policy")
|
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
|
// approvedIPs should contain all of machine's IPs if it matches the rule, so check for first
|
||||||
@ -985,8 +986,6 @@ func (h *Headscale) EnableAutoApprovedRoutes(machine *Machine) error {
|
|||||||
machine.EnabledRoutes = append(machine.EnabledRoutes, approvedRoute)
|
machine.EnabledRoutes = append(machine.EnabledRoutes, approvedRoute)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (machine *Machine) RoutesToProto() *v1.Routes {
|
func (machine *Machine) RoutesToProto() *v1.Routes {
|
||||||
|
Loading…
Reference in New Issue
Block a user