mirror of
https://github.com/juanfont/headscale.git
synced 2024-12-25 01:07:52 +00:00
Also notify peers when deleting ephemerals
This commit is contained in:
parent
c1e6157847
commit
ab61c87701
1
app.go
1
app.go
@ -135,6 +135,7 @@ func (h *Headscale) expireEphemeralNodesWorker() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Str("machine", m.Name).Msg("🤮 Cannot delete ephemeral machine from the database")
|
log.Error().Err(err).Str("machine", m.Name).Msg("🤮 Cannot delete ephemeral machine from the database")
|
||||||
}
|
}
|
||||||
|
h.notifyChangesToPeers(&m)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
23
machine.go
23
machine.go
@ -238,3 +238,26 @@ func (m *Machine) GetHostInfo() (*tailcfg.Hostinfo, error) {
|
|||||||
}
|
}
|
||||||
return &hostinfo, nil
|
return &hostinfo, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h *Headscale) notifyChangesToPeers(m *Machine) error {
|
||||||
|
peers, _ := h.getPeers(*m)
|
||||||
|
for _, p := range *peers {
|
||||||
|
pUp, ok := h.clientsPolling.Load(uint64(p.ID))
|
||||||
|
if ok {
|
||||||
|
log.Info().
|
||||||
|
Str("func", "notifyChangesToPeers").
|
||||||
|
Str("machine", m.Name).
|
||||||
|
Str("peer", m.Name).
|
||||||
|
Str("address", p.Addresses[0].String()).
|
||||||
|
Msgf("Notifying peer %s (%s)", p.Name, p.Addresses[0])
|
||||||
|
pUp.(chan []byte) <- []byte{}
|
||||||
|
} else {
|
||||||
|
log.Info().
|
||||||
|
Str("func", "notifyChangesToPeers").
|
||||||
|
Str("machine", m.Name).
|
||||||
|
Str("peer", m.Name).
|
||||||
|
Msgf("Peer %s does not appear to be polling", p.Name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
@ -169,25 +169,7 @@ func (h *Headscale) checkForNamespacesPendingUpdates() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
for _, m := range *machines {
|
for _, m := range *machines {
|
||||||
peers, _ := h.getPeers(m)
|
h.notifyChangesToPeers(&m)
|
||||||
for _, p := range *peers {
|
|
||||||
pUp, ok := h.clientsPolling.Load(uint64(p.ID))
|
|
||||||
if ok {
|
|
||||||
log.Info().
|
|
||||||
Str("func", "checkForNamespacesPendingUpdates").
|
|
||||||
Str("machine", m.Name).
|
|
||||||
Str("peer", m.Name).
|
|
||||||
Str("address", p.Addresses[0].String()).
|
|
||||||
Msgf("Notifying peer %s (%s)", p.Name, p.Addresses[0])
|
|
||||||
pUp.(chan []byte) <- []byte{}
|
|
||||||
} else {
|
|
||||||
log.Info().
|
|
||||||
Str("func", "checkForNamespacesPendingUpdates").
|
|
||||||
Str("machine", m.Name).
|
|
||||||
Str("peer", m.Name).
|
|
||||||
Msgf("Peer %s does not appear to be polling", p.Name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newV, err := h.getValue("namespaces_pending_updates")
|
newV, err := h.getValue("namespaces_pending_updates")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user