Random suffix only on collision.

0.16.0 introduced random suffixes to all machine given names
(DNS hostnames) regardless of collisions within a namespace.
This commit brings Headscale more inline with Tailscale by only
adding a suffix if the hostname will collide within the namespace.

The suffix generation differs from Tailscale.
See https://tailscale.com/kb/1098/machine-names/
This commit is contained in:
= authored and Kristoffer Dalby committed 2022-10-03 09:13:56 +02:00
1 parent 98f5b7f638
commit 2aebd2927d
5 files changed
+154 -49

No files matched your search

+2 -2
View File
@@ -1,4 +1,4 @@
//nolint
// nolint
package headscale
import (
@@ -479,7 +479,7 @@ func (api headscaleV1APIServer) DebugCreateMachine(
Hostname: "DebugTestMachine",
}
givenName, err := api.h.GenerateGivenName(request.GetName())
givenName, err := api.h.GenerateGivenName(namespace.Name, request.GetKey(), request.GetName())
if err != nil {
return nil, err
}