1
0
mirror of https://github.com/juanfont/headscale.git synced 2026-02-07 20:04:00 +01:00
This commit is contained in:
Samuel Batista 2026-02-07 08:24:16 +01:00 committed by GitHub
commit 007d49ba1d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 4 deletions

View File

@ -73,7 +73,10 @@ func (h *Headscale) handleRegister(
// When tailscaled restarts, it sends RegisterRequest with Auth=nil and Expiry=zero.
// Return the current node state without modification.
// See: https://github.com/juanfont/headscale/issues/2862
if req.Expiry.IsZero() && node.Expiry().Valid() && !node.IsExpired() {
// Note: node.Expiry().Valid() was too strict — tagged nodes have nil expiry,
// which caused zero-time requests to fall through to handleLogout and
// incorrectly set their expiry to 0001-01-01 (Go zero time).
if req.Expiry.IsZero() && !node.IsExpired() {
return nodeToRegisterResponse(node), nil
}

View File

@ -1097,9 +1097,14 @@ func (nv NodeView) TailNode(
derp = nv.Hostinfo().NetInfo().PreferredDERP()
}
var keyExpiry time.Time
if nv.Expiry().Valid() {
keyExpiry = nv.Expiry().Get()
// Default to far-future expiry for nodes without an explicit expiry
// (e.g. tagged nodes). A zero time.Time{} causes Tailscale clients to
// spin-loop on the netmap expiry timer (interpreted as math.MinInt64).
// Max safe time for int64 nanoseconds: 2262-04-11T23:47:16.854775807Z.
// We use 2262-01-01 (~4 month buffer). Year 9999 overflows.
keyExpiry := time.Date(2262, 1, 1, 0, 0, 0, 0, time.UTC)
if nv.Expiry().Valid() && !nv.Expiry().Get().IsZero() {
keyExpiry = nv.Expiry().Get()
}
primaryRoutes := primaryRouteFunc(nv.ID())