mirror of
https://github.com/juanfont/headscale.git
synced 2025-06-05 01:20:21 +02:00
fix route update outside of connection
there was a bug where routes would not be updated if they changed while a node was connected and it was not part of an autoapprove. Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
parent
bffa64219b
commit
8bb3129e26
@ -458,10 +458,14 @@ func (m *mapSession) handleEndpointUpdate() {
|
|||||||
// TODO(kradalby): I am not sure if we need this?
|
// TODO(kradalby): I am not sure if we need this?
|
||||||
nodesChangedHook(m.h.db, m.h.polMan, m.h.nodeNotifier)
|
nodesChangedHook(m.h.db, m.h.polMan, m.h.nodeNotifier)
|
||||||
|
|
||||||
// Approve routes if they are auto-approved by the policy.
|
// Approve any route that has been defined in policy as
|
||||||
// If any of them are approved, report them to the primary route tracker
|
// auto approved. Any change here is not important as any
|
||||||
// and send updates accordingly.
|
// actual state change will be detected when the route manager
|
||||||
if policy.AutoApproveRoutes(m.h.polMan, m.node) {
|
// is updated.
|
||||||
|
policy.AutoApproveRoutes(m.h.polMan, m.node)
|
||||||
|
|
||||||
|
// Update the routes of the given node in the route manager to
|
||||||
|
// see if an update needs to be sent.
|
||||||
if m.h.primaryRoutes.SetRoutes(m.node.ID, m.node.SubnetRoutes()...) {
|
if m.h.primaryRoutes.SetRoutes(m.node.ID, m.node.SubnetRoutes()...) {
|
||||||
ctx := types.NotifyCtx(m.ctx, "poll-primary-change", m.node.Hostname)
|
ctx := types.NotifyCtx(m.ctx, "poll-primary-change", m.node.Hostname)
|
||||||
m.h.nodeNotifier.NotifyAll(ctx, types.UpdateFull())
|
m.h.nodeNotifier.NotifyAll(ctx, types.UpdateFull())
|
||||||
@ -481,8 +485,6 @@ func (m *mapSession) handleEndpointUpdate() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if there has been a change to Hostname and update them
|
// Check if there has been a change to Hostname and update them
|
||||||
// in the database. Then send a Changed update
|
// in the database. Then send a Changed update
|
||||||
// (containing the whole node object) to peers to inform about
|
// (containing the whole node object) to peers to inform about
|
||||||
@ -506,8 +508,6 @@ func (m *mapSession) handleEndpointUpdate() {
|
|||||||
|
|
||||||
m.w.WriteHeader(http.StatusOK)
|
m.w.WriteHeader(http.StatusOK)
|
||||||
mapResponseEndpointUpdates.WithLabelValues("ok").Inc()
|
mapResponseEndpointUpdates.WithLabelValues("ok").Inc()
|
||||||
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mapSession) handleReadOnlyRequest() {
|
func (m *mapSession) handleReadOnlyRequest() {
|
||||||
@ -532,8 +532,6 @@ func (m *mapSession) handleReadOnlyRequest() {
|
|||||||
|
|
||||||
m.w.WriteHeader(http.StatusOK)
|
m.w.WriteHeader(http.StatusOK)
|
||||||
mapResponseReadOnly.WithLabelValues("ok").Inc()
|
mapResponseReadOnly.WithLabelValues("ok").Inc()
|
||||||
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func logTracePeerChange(hostname string, hostinfoChange bool, change *tailcfg.PeerChange) {
|
func logTracePeerChange(hostname string, hostinfoChange bool, change *tailcfg.PeerChange) {
|
||||||
|
Loading…
Reference in New Issue
Block a user