Integrate expiration fixes (#754) in TS2021 branch
This commit is contained in:
commit
e20e818a42
3 changed files with 18 additions and 0 deletions
10
machine.go
10
machine.go
|
@ -26,6 +26,7 @@ const (
|
|||
)
|
||||
ErrCouldNotConvertMachineInterface = Error("failed to convert machine interface")
|
||||
ErrHostnameTooLong = Error("Hostname too long")
|
||||
ErrDifferentRegisteredNamespace = Error("machine was previously registered with a different namespace")
|
||||
MachineGivenNameHashLength = 8
|
||||
MachineGivenNameTrimSize = 2
|
||||
)
|
||||
|
@ -805,6 +806,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.RegisterMethod = registrationMethod
|
||||
|
||||
|
@ -812,6 +818,10 @@ func (h *Headscale) RegisterMachineFromAuthCallback(
|
|||
registrationMachine,
|
||||
)
|
||||
|
||||
if err == nil {
|
||||
h.registrationCache.Delete(nodeKeyStr)
|
||||
}
|
||||
|
||||
return machine, err
|
||||
} else {
|
||||
return nil, ErrCouldNotConvertMachineInterface
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue