From e1e3feb6a810664c43ba5096c476a32a1dcab87c Mon Sep 17 00:00:00 2001 From: Juan Font Alonso Date: Thu, 11 Aug 2022 13:37:25 +0200 Subject: [PATCH] Add a sleep to reduce the impact of #727 --- api.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/api.go b/api.go index 8c400122..dcccea35 100644 --- a/api.go +++ b/api.go @@ -21,6 +21,7 @@ import ( ) const ( + registrationHoldoff = time.Second * 5 // TODO(juan): remove this once https://github.com/juanfont/headscale/issues/727 is fixed reservedResponseHeaderSize = 4 RegisterMethodAuthKey = "authkey" RegisterMethodOIDC = "oidc" @@ -237,9 +238,15 @@ func (h *Headscale) RegistrationHandler( Str("Followup", registerRequest.Followup). Msg("Machine is waiting for interactive login") - h.handleMachineRegistrationNew(writer, req, machineKey, registerRequest) + ticker := time.NewTicker(registrationHoldoff) + select { + case <-req.Context().Done(): + return + case <-ticker.C: + h.handleMachineRegistrationNew(writer, req, machineKey, registerRequest) - return + return + } } }