mirror of
https://github.com/juanfont/headscale.git
synced 2024-12-25 21:55:52 -05:00
Fix cli registration of expired machines
Signed-off-by: Laurent Marchaud <laurent@marchaud.com>
This commit is contained in:
parent
19455399f4
commit
c6ea9b4b80
7
api.go
7
api.go
@ -346,6 +346,13 @@ func (h *Headscale) RegistrationHandler(
|
|||||||
// The machine has expired
|
// The machine has expired
|
||||||
h.handleMachineExpired(writer, req, machineKey, registerRequest, *machine)
|
h.handleMachineExpired(writer, req, machineKey, registerRequest, *machine)
|
||||||
|
|
||||||
|
machine.Expiry = &time.Time{}
|
||||||
|
h.registrationCache.Set(
|
||||||
|
machineKeyStr,
|
||||||
|
*machine,
|
||||||
|
registerCacheExpiration,
|
||||||
|
)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
14
machine.go
14
machine.go
@ -24,8 +24,9 @@ const (
|
|||||||
ErrMachineNotFoundRegistrationCache = Error(
|
ErrMachineNotFoundRegistrationCache = Error(
|
||||||
"machine not found in registration cache",
|
"machine not found in registration cache",
|
||||||
)
|
)
|
||||||
ErrCouldNotConvertMachineInterface = Error("failed to convert machine interface")
|
errCouldNotConvertMachineInterface = Error("failed to convert machine interface")
|
||||||
ErrHostnameTooLong = Error("Hostname too long")
|
errHostnameTooLong = Error("Hostname too long")
|
||||||
|
errDifferentRegisteredNamespace = Error("machine was previously registered with a different namespace")
|
||||||
MachineGivenNameHashLength = 8
|
MachineGivenNameHashLength = 8
|
||||||
MachineGivenNameTrimSize = 2
|
MachineGivenNameTrimSize = 2
|
||||||
)
|
)
|
||||||
@ -789,6 +790,11 @@ func (h *Headscale) RegisterMachineFromAuthCallback(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Registration of expired machine with different namespace
|
||||||
|
if registrationMachine.ID != 0 && registrationMachine.NamespaceID != namespace.ID {
|
||||||
|
return nil, errDifferentRegisteredNamespace
|
||||||
|
}
|
||||||
|
|
||||||
registrationMachine.NamespaceID = namespace.ID
|
registrationMachine.NamespaceID = namespace.ID
|
||||||
registrationMachine.RegisterMethod = registrationMethod
|
registrationMachine.RegisterMethod = registrationMethod
|
||||||
|
|
||||||
@ -796,6 +802,10 @@ func (h *Headscale) RegisterMachineFromAuthCallback(
|
|||||||
registrationMachine,
|
registrationMachine,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if err == nil {
|
||||||
|
h.registrationCache.Delete(machineKeyStr)
|
||||||
|
}
|
||||||
|
|
||||||
return machine, err
|
return machine, err
|
||||||
} else {
|
} else {
|
||||||
return nil, ErrCouldNotConvertMachineInterface
|
return nil, ErrCouldNotConvertMachineInterface
|
||||||
|
Loading…
Reference in New Issue
Block a user