Protect against expiry nil

This commit is contained in:
Kristoffer Dalby 2022-03-02 07:15:20 +00:00
parent ec4dc68524
commit ef422e6988
2 changed files with 2 additions and 1 deletions

1
api.go
View file

@ -144,6 +144,7 @@ func (h *Headscale) RegistrationHandler(ctx *gin.Context) {
Name: req.Hostinfo.Hostname, Name: req.Hostinfo.Hostname,
NodeKey: NodePublicKeyStripPrefix(req.NodeKey), NodeKey: NodePublicKeyStripPrefix(req.NodeKey),
LastSeen: &now, LastSeen: &now,
Expiry: &time.Time{},
} }
if !req.Expiry.IsZero() { if !req.Expiry.IsZero() {

View file

@ -117,7 +117,7 @@ func (machine Machine) isExpired() bool {
// If Expiry is not set, the client has not indicated that // If Expiry is not set, the client has not indicated that
// it wants an expiry time, it is therefor considered // it wants an expiry time, it is therefor considered
// to mean "not expired" // to mean "not expired"
if machine.Expiry.IsZero() { if machine.Expiry == nil || machine.Expiry.IsZero() {
return false return false
} }