mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-11 21:27:31 +00:00
control/controlclient: only use a single DNS label as the hostname.
Fixes #971 Signed-off-by: David Anderson <danderson@tailscale.com>
This commit is contained in:
@@ -223,6 +223,14 @@ func NumLabels(hostname string) int {
|
||||
return strings.Count(hostname, ".")
|
||||
}
|
||||
|
||||
// FirstLabel returns the first DNS label of hostname.
|
||||
func FirstLabel(hostname string) string {
|
||||
if i := strings.IndexByte(hostname, '.'); i != -1 {
|
||||
return hostname[:i]
|
||||
}
|
||||
return hostname
|
||||
}
|
||||
|
||||
var separators = map[byte]bool{
|
||||
' ': true,
|
||||
'.': true,
|
||||
|
Reference in New Issue
Block a user