diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b5de68d..407933ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - Report if a machine is online in CLI more accurately [#1062](https://github.com/juanfont/headscale/pull/1062) - Added config option for custom DNS records [#1035](https://github.com/juanfont/headscale/pull/1035) - Expire nodes based on OIDC token expiry [#1067](https://github.com/juanfont/headscale/pull/1067) +- Remote ephemeral nodes on logout [#1098](https://github.com/juanfont/headscale/pull/1098) ## 0.17.1 (2022-12-05) diff --git a/protocol_common.go b/protocol_common.go index 0abf52ff..e74104d5 100644 --- a/protocol_common.go +++ b/protocol_common.go @@ -622,6 +622,20 @@ func (h *Headscale) handleMachineLogOutCommon( Caller(). Err(err). Msg("Failed to write response") + + return + } + + if machine.isEphemeral() { + err = h.HardDeleteMachine(&machine) + if err != nil { + log.Error(). + Err(err). + Str("machine", machine.Hostname). + Msg("Cannot delete ephemeral machine from the database") + } + + return } log.Info().