mirror of
https://github.com/juanfont/headscale.git
synced 2025-09-25 17:51:11 +02:00
mapper: send selfupdate on NewOrUpdate change
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
parent
f534d429db
commit
7f469714ed
@ -108,7 +108,13 @@ func generateMapResponse(nodeID types.NodeID, version tailcfg.CapabilityVersion,
|
|||||||
}
|
}
|
||||||
|
|
||||||
case change.NodeNewOrUpdate:
|
case change.NodeNewOrUpdate:
|
||||||
mapResp, err = mapper.peerChangeResponse(nodeID, version, c.NodeID)
|
// If the node is the one being updated, we send a "full" self update
|
||||||
|
// to ensure the node sees changes to its own properties (e.g., hostname/DNS name changes)
|
||||||
|
if c.IsSelfUpdate(nodeID) {
|
||||||
|
mapResp, err = mapper.selfMapResponse(nodeID, version)
|
||||||
|
} else {
|
||||||
|
mapResp, err = mapper.peerChangeResponse(nodeID, version, c.NodeID)
|
||||||
|
}
|
||||||
|
|
||||||
case change.NodeRemove:
|
case change.NodeRemove:
|
||||||
mapResp, err = mapper.peerRemovedResponse(nodeID, c.NodeID)
|
mapResp, err = mapper.peerRemovedResponse(nodeID, c.NodeID)
|
||||||
@ -116,7 +122,7 @@ func generateMapResponse(nodeID types.NodeID, version tailcfg.CapabilityVersion,
|
|||||||
case change.NodeKeyExpiry:
|
case change.NodeKeyExpiry:
|
||||||
// If the node is the one whose key is expiring, we send a "full" self update
|
// If the node is the one whose key is expiring, we send a "full" self update
|
||||||
// as nodes will ignore patch updates about themselves (?).
|
// as nodes will ignore patch updates about themselves (?).
|
||||||
if nodeID == c.NodeID {
|
if c.IsSelfUpdate(nodeID) {
|
||||||
mapResp, err = mapper.selfMapResponse(nodeID, version)
|
mapResp, err = mapper.selfMapResponse(nodeID, version)
|
||||||
// mapResp, err = mapper.fullMapResponse(nodeID, version)
|
// mapResp, err = mapper.fullMapResponse(nodeID, version)
|
||||||
} else {
|
} else {
|
||||||
|
@ -130,6 +130,11 @@ func RemoveUpdatesForSelf(id types.NodeID, cs []ChangeSet) (ret []ChangeSet) {
|
|||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsSelfUpdate reports whether this ChangeSet represents an update to the given node itself.
|
||||||
|
func (c ChangeSet) IsSelfUpdate(nodeID types.NodeID) bool {
|
||||||
|
return c.NodeID == nodeID
|
||||||
|
}
|
||||||
|
|
||||||
func (c ChangeSet) AlsoSelf() bool {
|
func (c ChangeSet) AlsoSelf() bool {
|
||||||
// If NodeID is 0, it means this ChangeSet is not related to a specific node,
|
// If NodeID is 0, it means this ChangeSet is not related to a specific node,
|
||||||
// so we consider it as a change that should be sent to all nodes.
|
// so we consider it as a change that should be sent to all nodes.
|
||||||
|
Loading…
Reference in New Issue
Block a user