adding some sleep on re-registration after machine expired (#1256)

This commit is contained in:
Kurnia D Win 2023-03-20 17:14:34 +07:00 committed by GitHub
parent e38efd3cfa
commit 2560c32378
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -131,11 +131,10 @@ func (h *Headscale) handleRegisterCommon(
Bool("noise", isNoise). Bool("noise", isNoise).
Msg("Machine is waiting for interactive login") Msg("Machine is waiting for interactive login")
ticker := time.NewTicker(registrationHoldoff)
select { select {
case <-req.Context().Done(): case <-req.Context().Done():
return return
case <-ticker.C: case <-time.After(registrationHoldoff):
h.handleNewMachineCommon(writer, registerRequest, machineKey, isNoise) h.handleNewMachineCommon(writer, registerRequest, machineKey, isNoise)
return return
@ -265,6 +264,14 @@ func (h *Headscale) handleRegisterCommon(
return return
} }
if registerRequest.Followup != "" {
select {
case <-req.Context().Done():
return
case <-time.After(registrationHoldoff):
}
}
// The machine has expired or it is logged out // The machine has expired or it is logged out
h.handleMachineExpiredOrLoggedOutCommon(writer, registerRequest, *machine, machineKey, isNoise) h.handleMachineExpiredOrLoggedOutCommon(writer, registerRequest, *machine, machineKey, isNoise)