mirror of
https://github.com/juanfont/headscale.git
synced 2026-01-23 02:24:10 +00:00
Merge 91711ec234 into 606e5f68a0
This commit is contained in:
commit
dc198f06b8
2 changed files with 16 additions and 8 deletions
|
|
@ -585,17 +585,25 @@ func (node *Node) ApplyHostnameFromHostInfo(hostInfo *tailcfg.Hostinfo) {
|
|||
return
|
||||
}
|
||||
|
||||
newHostname := strings.ToLower(hostInfo.Hostname)
|
||||
if err := util.ValidateHostname(newHostname); err != nil {
|
||||
newHostname, err := util.NormaliseHostname(hostInfo.Hostname)
|
||||
if err != nil {
|
||||
log.Warn().
|
||||
Str("node.id", node.ID.String()).
|
||||
Str("current_hostname", node.Hostname).
|
||||
Str("rejected_hostname", hostInfo.Hostname).
|
||||
Str("original_hostname", hostInfo.Hostname).
|
||||
Err(err).
|
||||
Msg("Rejecting invalid hostname update from hostinfo")
|
||||
Msg("Hostname normalization failed, keeping current hostname")
|
||||
return
|
||||
}
|
||||
|
||||
if hostInfo.Hostname != newHostname {
|
||||
log.Info().
|
||||
Str("node.id", node.ID.String()).
|
||||
Str("original", hostInfo.Hostname).
|
||||
Str("sanitized", newHostname).
|
||||
Msg("Hostname sanitized during update")
|
||||
}
|
||||
|
||||
if node.Hostname != newHostname {
|
||||
log.Trace().
|
||||
Str("node.id", node.ID.String()).
|
||||
|
|
|
|||
|
|
@ -287,12 +287,12 @@ func EnsureHostname(hostinfo *tailcfg.Hostinfo, machineKey, nodeKey string) stri
|
|||
return fmt.Sprintf("node-%s", keyPrefix)
|
||||
}
|
||||
|
||||
lowercased := strings.ToLower(hostinfo.Hostname)
|
||||
if err := ValidateHostname(lowercased); err == nil {
|
||||
return lowercased
|
||||
normalized, err := NormaliseHostname(hostinfo.Hostname)
|
||||
if err != nil {
|
||||
return InvalidString()
|
||||
}
|
||||
|
||||
return InvalidString()
|
||||
return normalized
|
||||
}
|
||||
|
||||
// GenerateRegistrationKey generates a vanity key for tracking web authentication
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue