cmd/tailscale: de-punycode hostnames in status display

Still show original, but show de-punycode version in parens,
similar to how we show DNS-less hostnames.

Change-Id: I7e57da5e4029c5b49e8cd3014c350eddd2b3c338
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
pull/6531/head
Brad Fitzpatrick 2 years ago committed by Brad Fitzpatrick
parent 5676d201d6
commit 3b73727e39

@ -19,6 +19,7 @@ import (
"github.com/peterbourgon/ff/v3/ffcli"
"github.com/toqueteos/webbrowser"
"golang.org/x/net/idna"
"tailscale.com/ipn"
"tailscale.com/ipn/ipnstate"
"tailscale.com/net/interfaces"
@ -248,6 +249,11 @@ func isRunningOrStarting(st *ipnstate.Status) (description string, ok bool) {
func dnsOrQuoteHostname(st *ipnstate.Status, ps *ipnstate.PeerStatus) string {
baseName := dnsname.TrimSuffix(ps.DNSName, st.MagicDNSSuffix)
if baseName != "" {
if strings.HasPrefix(baseName, "xn-") {
if u, err := idna.ToUnicode(baseName); err == nil {
return fmt.Sprintf("%s (%s)", baseName, u)
}
}
return baseName
}
return fmt.Sprintf("(%q)", dnsname.SanitizeHostname(ps.HostName))

Loading…
Cancel
Save