control/controlclient: only use a single DNS label as the hostname.
Fixes #971 Signed-off-by: David Anderson <danderson@tailscale.com>pull/1718/head
parent
4f3203556d
commit
7055f870f8
|
@ -46,6 +46,7 @@ import (
|
||||||
"tailscale.com/types/opt"
|
"tailscale.com/types/opt"
|
||||||
"tailscale.com/types/persist"
|
"tailscale.com/types/persist"
|
||||||
"tailscale.com/types/wgkey"
|
"tailscale.com/types/wgkey"
|
||||||
|
"tailscale.com/util/dnsname"
|
||||||
"tailscale.com/util/systemd"
|
"tailscale.com/util/systemd"
|
||||||
"tailscale.com/version"
|
"tailscale.com/version"
|
||||||
"tailscale.com/wgengine/filter"
|
"tailscale.com/wgengine/filter"
|
||||||
|
@ -179,6 +180,7 @@ var osVersion func() string // non-nil on some platforms
|
||||||
|
|
||||||
func NewHostinfo() *tailcfg.Hostinfo {
|
func NewHostinfo() *tailcfg.Hostinfo {
|
||||||
hostname, _ := os.Hostname()
|
hostname, _ := os.Hostname()
|
||||||
|
hostname = dnsname.FirstLabel(hostname)
|
||||||
var osv string
|
var osv string
|
||||||
if osVersion != nil {
|
if osVersion != nil {
|
||||||
osv = osVersion()
|
osv = osVersion()
|
||||||
|
|
|
@ -223,6 +223,14 @@ func NumLabels(hostname string) int {
|
||||||
return strings.Count(hostname, ".")
|
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{
|
var separators = map[byte]bool{
|
||||||
' ': true,
|
' ': true,
|
||||||
'.': true,
|
'.': true,
|
||||||
|
|
Loading…
Reference in New Issue