Skip to content

Commit

Permalink
Add a sleep to reduce the impact of juanfont#727
Browse files Browse the repository at this point in the history
  • Loading branch information
juanfont committed Aug 11, 2022
1 parent 8e56d8b commit e1e3feb
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
}
}

Expand Down

0 comments on commit e1e3feb

Please sign in to comment.