From 5a63c3022205c4e22e6143a2f723b2e5f9e087bd Mon Sep 17 00:00:00 2001 From: Pallab Pain Date: Thu, 11 Jan 2024 11:15:34 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(routes):=20corrects=20the=20?= =?UTF-8?q?logic=20in=20isUniquePrefix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hscontrol/routes.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hscontrol/routes.go b/hscontrol/routes.go index 84bd6a18dae..2b38140784e 100644 --- a/hscontrol/routes.go +++ b/hscontrol/routes.go @@ -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 ( @@ -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 } } @@ -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