Skip to content

Commit

Permalink
🐛 fix(routes): corrects the logic in isUniquePrefix
Browse files Browse the repository at this point in the history
  • Loading branch information
pallabpain committed Jan 11, 2024
1 parent ec93707 commit 5a63c30
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions hscontrol/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import (
"fmt"
"net/netip"

v1 "github.com/juanfont/headscale/gen/go/headscale/v1"
"github.com/rs/zerolog/log"
"google.golang.org/protobuf/types/known/timestamppb"
"gorm.io/gorm"

v1 "github.com/juanfont/headscale/gen/go/headscale/v1"
)

const (
Expand Down Expand Up @@ -211,7 +212,7 @@ func (h *Headscale) isUniquePrefix(route Route) bool {
for _, r := range routes {
// Return false, if there are more than one uniquePrefix for the same
// user. Else, true. This allows having the same prefix for two users.
if route.Machine.UserID == r.Machine.UserID && route.Machine.isOnline() {
if route.Machine.UserID == r.Machine.UserID && r.Machine.isOnline() {
return false
}
}
Expand Down Expand Up @@ -367,7 +368,7 @@ func (h *Headscale) handlePrimarySubnetFailover() error {

var newPrimaryRoute *Route
for pos, r := range newPrimaryRoutes {
if r.Machine.isOnline() {
if r.Machine.UserID == route.Machine.UserID && r.Machine.isOnline() {
newPrimaryRoute = &newPrimaryRoutes[pos]

break
Expand Down

0 comments on commit 5a63c30

Please sign in to comment.