Rename name -> hostname, nickname -> givenname

This commit is contained in:
Kristoffer Dalby 2022-04-24 20:54:38 +01:00
parent 8845938881
commit 6e2768097a
10 changed files with 104 additions and 96 deletions

17
api.go
View file

@ -133,7 +133,7 @@ func (h *Headscale) RegistrationHandler(ctx *gin.Context) {
return
}
hname, err := NormalizeToFQDNRules(
normalizedHostname, err := NormalizeToFQDNRules(
req.Hostinfo.Hostname,
h.cfg.OIDC.StripEmaildomain,
)
@ -153,7 +153,8 @@ func (h *Headscale) RegistrationHandler(ctx *gin.Context) {
// happens
newMachine := Machine{
MachineKey: machineKeyStr,
Name: hname,
Hostname: req.Hostinfo.Hostname,
GivenName: normalizedHostname,
NodeKey: NodePublicKeyStripPrefix(req.NodeKey),
LastSeen: &now,
Expiry: &time.Time{},
@ -361,7 +362,7 @@ func (h *Headscale) handleMachineLogOut(
resp := tailcfg.RegisterResponse{}
log.Info().
Str("machine", machine.Name).
Str("machine", machine.Hostname).
Msg("Client requested logout")
h.ExpireMachine(&machine)
@ -391,7 +392,7 @@ func (h *Headscale) handleMachineValidRegistration(
// The machine registration is valid, respond with redirect to /map
log.Debug().
Str("machine", machine.Name).
Str("machine", machine.Hostname).
Msg("Client is registered and we have the current NodeKey. All clear to /map")
resp.AuthURL = ""
@ -426,7 +427,7 @@ func (h *Headscale) handleMachineExpired(
// The client has registered before, but has expired
log.Debug().
Str("machine", machine.Name).
Str("machine", machine.Hostname).
Msg("Machine registration has expired. Sending a authurl to register")
if registerRequest.Auth.AuthKey != "" {
@ -469,7 +470,7 @@ func (h *Headscale) handleMachineRefreshKey(
resp := tailcfg.RegisterResponse{}
log.Debug().
Str("machine", machine.Name).
Str("machine", machine.Hostname).
Msg("We have the OldNodeKey in the database. This is a key refresh")
machine.NodeKey = NodePublicKeyStripPrefix(registerRequest.NodeKey)
h.db.Save(&machine)
@ -594,7 +595,7 @@ func (h *Headscale) handleAuthKey(
if machine != nil {
log.Trace().
Caller().
Str("machine", machine.Name).
Str("machine", machine.Hostname).
Msg("machine already registered, refreshing with new auth key")
machine.NodeKey = nodeKey
@ -603,7 +604,7 @@ func (h *Headscale) handleAuthKey(
} else {
now := time.Now().UTC()
machineToRegister := Machine{
Name: registerRequest.Hostinfo.Hostname,
Hostname: registerRequest.Hostinfo.Hostname,
NamespaceID: pak.Namespace.ID,
MachineKey: machineKeyStr,
RegisterMethod: RegisterMethodAuthKey,