headscale/hscontrol/util
Kristoffer Dalby d6dfdc100c hscontrol: route hostname handling through dnsname and NodeStore
Ingest (registration and MapRequest updates) now calls
dnsname.SanitizeHostname directly and lets NodeStore auto-bump on
collision. Admin rename uses dnsname.ValidLabel + SetGivenName so
conflicts are surfaced to the caller instead of silently mutated.

Three duplicate invalidDNSRegex definitions, the old NormaliseHostname
and ValidateHostname helpers, EnsureHostname, InvalidString,
ApplyHostnameFromHostInfo, GivenNameHasBeenChanged, generateGivenName
and EnsureUniqueGivenName are removed along with their tests.
ValidateHostname's username half is retained as ValidateUsername for
users.go.

The SaaS-matching collision rule replaces the random "invalid-xxxxxx"
fallback and the 8-character hash suffix; the empty-input fallback is
the literal "node". TestUpdateHostnameFromClient now exercises the
rewrite end-to-end with awkward macOS/Windows names.

Fixes #3188
Fixes #2926
Fixes #2343
Fixes #2762
Fixes #2449
Updates #2177
Updates #2121
Updates #363
2026-04-18 15:12:21 +01:00
..
zlog hscontrol/types: silence zerolog by default in tests 2026-04-17 16:31:49 +01:00
addr.go all: fix golangci-lint issues (#3064) 2026-02-06 21:45:32 +01:00
addr_test.go all: fix golangci-lint issues (#3064) 2026-02-06 21:45:32 +01:00
const.go Split code into modules 2023-05-26 12:24:50 +02:00
dns.go hscontrol: route hostname handling through dnsname and NodeStore 2026-04-18 15:12:21 +01:00
dns_test.go hscontrol: route hostname handling through dnsname and NodeStore 2026-04-18 15:12:21 +01:00
file.go all: fix golangci-lint issues (#3064) 2026-02-06 21:45:32 +01:00
key.go errors: rewrite errors to follow go best practices 2026-02-06 07:40:29 +01:00
log.go all: fix golangci-lint issues (#3064) 2026-02-06 21:45:32 +01:00
net.go integration: replace time.Sleep with assert.EventuallyWithT (#2680) 2025-07-10 23:38:55 +02:00
norace.go mapper/batcher: restructure internals for correctness 2026-03-14 02:52:28 -07:00
prompt.go all: fix golangci-lint issues (#3064) 2026-02-06 21:45:32 +01:00
prompt_test.go all: fix golangci-lint issues (#3064) 2026-02-06 21:45:32 +01:00
race.go mapper/batcher: restructure internals for correctness 2026-03-14 02:52:28 -07:00
string.go hscontrol: route hostname handling through dnsname and NodeStore 2026-04-18 15:12:21 +01:00
string_test.go allow users to be defined with @ in v1 (#2495) 2025-03-30 11:19:05 +00:00
test.go all: upgrade to Go 1.26rc2 and modernize codebase 2026-02-08 12:35:23 +01:00
util.go hscontrol: route hostname handling through dnsname and NodeStore 2026-04-18 15:12:21 +01:00
util_test.go hscontrol: route hostname handling through dnsname and NodeStore 2026-04-18 15:12:21 +01:00