From afae1ff7b6b2097fe266045c74c6b5acfddd5890 Mon Sep 17 00:00:00 2001 From: Juan Font Date: Tue, 27 Dec 2022 11:33:51 +0000 Subject: [PATCH] Delete ephemeral machines on logout Update changelog Use dedicated method to delete --- CHANGELOG.md | 1 + protocol_common.go | 14 ++++++++++++++ 2 files changed, 15 insertions(+) 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().