mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-23 18:15:26 +00:00
Generate unique givennames for hosts joining (and debug added)
This commit is contained in:
parent
03cccd60a6
commit
5fa3016703
8
api.go
8
api.go
@ -134,11 +134,7 @@ func (h *Headscale) RegistrationHandler(ctx *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// TODO(kradalby): We need these fields to be unique, we need to add a hash or something at the end.
|
||||
normalizedHostname, err := NormalizeToFQDNRules(
|
||||
req.Hostinfo.Hostname,
|
||||
h.cfg.OIDC.StripEmaildomain,
|
||||
)
|
||||
givenName, err := h.GenerateGivenName(req.Hostinfo.Hostname)
|
||||
if err != nil {
|
||||
log.Error().
|
||||
Caller().
|
||||
@ -156,7 +152,7 @@ func (h *Headscale) RegistrationHandler(ctx *gin.Context) {
|
||||
newMachine := Machine{
|
||||
MachineKey: machineKeyStr,
|
||||
Hostname: req.Hostinfo.Hostname,
|
||||
GivenName: normalizedHostname,
|
||||
GivenName: givenName,
|
||||
NodeKey: NodePublicKeyStripPrefix(req.NodeKey),
|
||||
LastSeen: &now,
|
||||
Expiry: &time.Time{},
|
||||
|
@ -394,9 +394,15 @@ func (api headscaleV1APIServer) DebugCreateMachine(
|
||||
Hostname: "DebugTestMachine",
|
||||
}
|
||||
|
||||
givenName, err := api.h.GenerateGivenName(request.GetName())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
newMachine := Machine{
|
||||
MachineKey: request.GetKey(),
|
||||
Hostname: request.GetName(),
|
||||
GivenName: givenName,
|
||||
Namespace: *namespace,
|
||||
|
||||
Expiry: &time.Time{},
|
||||
|
Loading…
Reference in New Issue
Block a user