mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-30 02:43:05 +00:00
Merge pull request #754 from Aluxima/expired-machine-registration
Fix cli registration of expired machines
This commit is contained in:
commit
061e2fe4b4
3 changed files with 18 additions and 0 deletions
|
@ -3,6 +3,7 @@
|
||||||
## 0.17.0 (2022-XX-XX)
|
## 0.17.0 (2022-XX-XX)
|
||||||
|
|
||||||
- Add ability to connect to PostgreSQL over TLS/SSL [#745](https://github.com/juanfont/headscale/pull/745)
|
- Add ability to connect to PostgreSQL over TLS/SSL [#745](https://github.com/juanfont/headscale/pull/745)
|
||||||
|
- Fix CLI registration of expired machines [#754](https://github.com/juanfont/headscale/pull/754)
|
||||||
|
|
||||||
## 0.16.3 (2022-08-17)
|
## 0.16.3 (2022-08-17)
|
||||||
|
|
||||||
|
|
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(
|
||||||
|
NodePublicKeyStripPrefix(registerRequest.NodeKey),
|
||||||
|
*machine,
|
||||||
|
registerCacheExpiration,
|
||||||
|
)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
10
machine.go
10
machine.go
|
@ -26,6 +26,7 @@ const (
|
||||||
)
|
)
|
||||||
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(nodeKeyStr)
|
||||||
|
}
|
||||||
|
|
||||||
return machine, err
|
return machine, err
|
||||||
} else {
|
} else {
|
||||||
return nil, ErrCouldNotConvertMachineInterface
|
return nil, ErrCouldNotConvertMachineInterface
|
||||||
|
|
Loading…
Reference in a new issue