mirror of
https://github.com/juanfont/headscale.git
synced 2025-08-12 04:47:36 +00:00
Split up MapResponse
This commits extends the mapper with functions for creating "delta" MapResponses for different purposes (peer changed, peer removed, derp). This wires up the new state management with a new StateUpdate struct letting the poll worker know what kind of update to send to the connected nodes. Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:

committed by
Kristoffer Dalby

parent
66ff1fcd40
commit
4b65cf48d0
@@ -274,7 +274,7 @@ func (hsdb *HSDatabase) HandlePrimarySubnetFailover() error {
|
||||
log.Error().Err(err).Msg("error getting routes")
|
||||
}
|
||||
|
||||
routesChanged := false
|
||||
changedMachines := make([]uint64, 0)
|
||||
for pos, route := range routes {
|
||||
if route.IsExitRoute() {
|
||||
continue
|
||||
@@ -295,7 +295,7 @@ func (hsdb *HSDatabase) HandlePrimarySubnetFailover() error {
|
||||
return err
|
||||
}
|
||||
|
||||
routesChanged = true
|
||||
changedMachines = append(changedMachines, route.MachineID)
|
||||
|
||||
continue
|
||||
}
|
||||
@@ -369,12 +369,15 @@ func (hsdb *HSDatabase) HandlePrimarySubnetFailover() error {
|
||||
return err
|
||||
}
|
||||
|
||||
routesChanged = true
|
||||
changedMachines = append(changedMachines, route.MachineID)
|
||||
}
|
||||
}
|
||||
|
||||
if routesChanged {
|
||||
hsdb.notifier.NotifyAll()
|
||||
if len(changedMachines) > 0 {
|
||||
hsdb.notifier.NotifyAll(types.StateUpdate{
|
||||
Type: types.StatePeerChanged,
|
||||
Changed: changedMachines,
|
||||
})
|
||||
}
|
||||
|
||||
return nil
|
||||
|
Reference in New Issue
Block a user