Skip to content

Commit

Permalink
move MapResponse peer logic into function and reuse
Browse files Browse the repository at this point in the history
Signed-off-by: Kristoffer Dalby <[email protected]>
  • Loading branch information
kradalby committed Sep 19, 2023
1 parent 387aa03 commit 432e975
Show file tree
Hide file tree
Showing 7 changed files with 193 additions and 173 deletions.
2 changes: 2 additions & 0 deletions hscontrol/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ type Headscale struct {

shutdownChan chan struct{}
pollNetMapStreamWG sync.WaitGroup

pollStreamOpenMu sync.Mutex
}

func NewHeadscale(cfg *types.Config) (*Headscale, error) {
Expand Down
6 changes: 4 additions & 2 deletions hscontrol/db/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,8 @@ func (hsdb *HSDatabase) handlePrimarySubnetFailover() error {
continue
}

machine := &route.Machine

if !route.IsPrimary {
_, err := hsdb.getPrimaryRoute(netip.Prefix(route.Prefix))
if hsdb.isUniquePrefix(route) || errors.Is(err, gorm.ErrRecordNotFound) {
Expand All @@ -355,7 +357,7 @@ func (hsdb *HSDatabase) handlePrimarySubnetFailover() error {
return err
}

changedMachines = append(changedMachines, &route.Machine)
changedMachines = append(changedMachines, machine)

continue
}
Expand Down Expand Up @@ -429,7 +431,7 @@ func (hsdb *HSDatabase) handlePrimarySubnetFailover() error {
return err
}

changedMachines = append(changedMachines, &route.Machine)
changedMachines = append(changedMachines, machine)
}
}

Expand Down
Loading

0 comments on commit 432e975

Please sign in to comment.