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 b6e39eb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@

- Code reorganisation, a lot of code has moved, please review the following PRs accordingly [#1444](https://github.com/juanfont/headscale/pull/1444)

## 0.22.3-rr (2023-XX-XX)
## 0.22.4-rr (2024-XX-XX)
### Fixed
- Subnet failover handler checks for user ID when finding new primary route

## 0.22.3-rr (2023-XX-28)
### Changes
- Set max open and idle connections for postgres
- Allows conflicting subnet ranges across users
Expand Down
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 b6e39eb

Please sign in to comment.