Skip to content

Commit

Permalink
locks and db cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Kristoffer Dalby <[email protected]>
  • Loading branch information
kradalby committed Jul 18, 2023
1 parent 5b8053f commit 7071644
Show file tree
Hide file tree
Showing 10 changed files with 204 additions and 200 deletions.
7 changes: 4 additions & 3 deletions hscontrol/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ func (h *Headscale) handleAuthKey(

machine.NodeKey = nodeKey
machine.AuthKeyID = uint(pak.ID)
err := h.db.RefreshMachine(machine, registerRequest.Expiry)
err := h.db.MachineSetExpiry(machine, registerRequest.Expiry)
if err != nil {
log.Error().
Caller().
Expand Down Expand Up @@ -510,7 +510,8 @@ func (h *Headscale) handleMachineLogOut(
Str("machine", machine.Hostname).
Msg("Client requested logout")

err := h.db.ExpireMachine(&machine)
now := time.Now()
err := h.db.MachineSetExpiry(&machine, now)
if err != nil {
log.Error().
Caller().
Expand Down Expand Up @@ -552,7 +553,7 @@ func (h *Headscale) handleMachineLogOut(
}

if machine.IsEphemeral() {
err = h.db.HardDeleteMachine(&machine)
err = h.db.DeleteMachine(&machine)
if err != nil {
log.Error().
Err(err).
Expand Down
Loading

0 comments on commit 7071644

Please sign in to comment.