1
0
mirror of https://github.com/juanfont/headscale.git synced 2024-12-20 19:09:07 +01:00

Update cli registration with new method

This commit is contained in:
Kristoffer Dalby 2022-02-27 18:42:43 +01:00
parent fd1e4a1dcd
commit caffbd8956

View File

@ -159,9 +159,27 @@ func (api headscaleV1APIServer) RegisterMachine(
Str("namespace", request.GetNamespace()).
Str("machine_key", request.GetKey()).
Msg("Registering machine")
// TODO(kradalby): Currently, if it fails to find a requested expiry, non will be set
// This means that if a user is to slow with register a machine, it will possibly not
// have the correct expiry.
requestedTime := time.Time{}
if requestedTimeIf, found := api.h.requestedExpiryCache.Get(request.GetKey()); found {
log.Trace().
Caller().
Str("machine", request.Key).
Msg("Expiry time found in cache, assigning to node")
if reqTime, ok := requestedTimeIf.(time.Time); ok {
requestedTime = reqTime
}
}
machine, err := api.h.RegisterMachine(
request.GetKey(),
request.GetNamespace(),
RegisterMethodCLI,
&requestedTime,
nil, nil, nil,
)
if err != nil {
return nil, err