From 44a5372c531d8118a3b2b01167640003f8f16365 Mon Sep 17 00:00:00 2001 From: Adrien Raffin-Caboisse Date: Thu, 3 Mar 2022 23:52:25 +0100 Subject: [PATCH] fix(poll): Normalize hostname This function is called often. Normalization of the hostname will be written in database. --- poll.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/poll.go b/poll.go index 1ae8cd0d..5723a3d6 100644 --- a/poll.go +++ b/poll.go @@ -83,7 +83,18 @@ func (h *Headscale) PollNetMapHandler(ctx *gin.Context) { Str("machine", machine.Name). Msg("Found machine in database") - machine.Name = req.Hostinfo.Hostname + hname, err := NormalizeNamespaceName( + req.Hostinfo.Hostname, + h.cfg.OIDC.StripEmaildomain, + ) + if err != nil { + log.Error(). + Caller(). + Str("func", "handleAuthKey"). + Str("hostinfo.name", req.Hostinfo.Hostname). + Err(err) + } + machine.Name = hname machine.HostInfo = HostInfo(*req.Hostinfo) machine.DiscoKey = DiscoPublicKeyStripPrefix(req.DiscoKey) now := time.Now().UTC()