From 802eb931d1ffcddad29bf3393b1240a4b734adde Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Tue, 17 May 2022 22:02:18 +0200 Subject: [PATCH] Make sure givenname is set for preauthkeys --- api.go | 13 +++++++++++++ integration_embedded_derp_test.go | 2 ++ 2 files changed, 15 insertions(+) diff --git a/api.go b/api.go index b4e3a7dd..a47857d1 100644 --- a/api.go +++ b/api.go @@ -601,8 +601,21 @@ func (h *Headscale) handleAuthKey( h.RefreshMachine(machine, registerRequest.Expiry) } else { now := time.Now().UTC() + + givenName, err := h.GenerateGivenName(registerRequest.Hostinfo.Hostname) + if err != nil { + log.Error(). + Caller(). + Str("func", "RegistrationHandler"). + Str("hostinfo.name", registerRequest.Hostinfo.Hostname). + Err(err) + + return + } + machineToRegister := Machine{ Hostname: registerRequest.Hostinfo.Hostname, + GivenName: givenName, NamespaceID: pak.Namespace.ID, MachineKey: machineKeyStr, RegisterMethod: RegisterMethodAuthKey, diff --git a/integration_embedded_derp_test.go b/integration_embedded_derp_test.go index 69b427f7..5f388694 100644 --- a/integration_embedded_derp_test.go +++ b/integration_embedded_derp_test.go @@ -356,6 +356,8 @@ func (s *IntegrationDERPTestSuite) TestPingAllPeersByHostname() { hostnames, err := getDNSNames(&s.headscale) assert.Nil(s.T(), err) + log.Printf("Hostnames: %#v\n", hostnames) + for hostname, tailscale := range s.tailscales { for _, peername := range hostnames { if strings.Contains(peername, hostname) {