From 2560c323781ad922ece28cf30aa333bb6cbc3d3f Mon Sep 17 00:00:00 2001 From: Kurnia D Win Date: Mon, 20 Mar 2023 17:14:34 +0700 Subject: [PATCH] adding some sleep on re-registration after machine expired (#1256) --- protocol_common.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/protocol_common.go b/protocol_common.go index 77a5b91e..2a30046f 100644 --- a/protocol_common.go +++ b/protocol_common.go @@ -131,11 +131,10 @@ func (h *Headscale) handleRegisterCommon( Bool("noise", isNoise). Msg("Machine is waiting for interactive login") - ticker := time.NewTicker(registrationHoldoff) select { case <-req.Context().Done(): return - case <-ticker.C: + case <-time.After(registrationHoldoff): h.handleNewMachineCommon(writer, registerRequest, machineKey, isNoise) return @@ -265,6 +264,14 @@ func (h *Headscale) handleRegisterCommon( return } + if registerRequest.Followup != "" { + select { + case <-req.Context().Done(): + return + case <-time.After(registrationHoldoff): + } + } + // The machine has expired or it is logged out h.handleMachineExpiredOrLoggedOutCommon(writer, registerRequest, *machine, machineKey, isNoise)