cmd/hello: chop DNS name at first dot

pull/1328/head
Brad Fitzpatrick 3 years ago
parent 6075135e0a
commit 5378776043

@ -131,7 +131,7 @@ func root(w http.ResponseWriter, r *http.Request) {
DisplayName: who.UserProfile.DisplayName,
LoginName: who.UserProfile.LoginName,
ProfilePicURL: who.UserProfile.ProfilePicURL,
MachineName: who.Node.ComputedName,
MachineName: firstLabel(who.Node.ComputedName),
MachineOS: who.Node.Hostinfo.OS,
IP: ip,
}
@ -140,6 +140,14 @@ func root(w http.ResponseWriter, r *http.Request) {
tmpl.Execute(w, data)
}
// firstLabel s up until the first period, if any.
func firstLabel(s string) string {
if i := strings.Index(s, "."); i != -1 {
return s[:i]
}
return s
}
// tsSockClient does HTTP requests to the local Tailscale daemon.
// The hostname in the HTTP request is ignored.
var tsSockClient = &http.Client{

Loading…
Cancel
Save