mirror of
https://github.com/tailscale/tailscale.git
synced 2025-01-07 08:07:42 +00:00
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>
This commit is contained in:
parent
5676d201d6
commit
3b73727e39
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
"github.com/peterbourgon/ff/v3/ffcli"
|
"github.com/peterbourgon/ff/v3/ffcli"
|
||||||
"github.com/toqueteos/webbrowser"
|
"github.com/toqueteos/webbrowser"
|
||||||
|
"golang.org/x/net/idna"
|
||||||
"tailscale.com/ipn"
|
"tailscale.com/ipn"
|
||||||
"tailscale.com/ipn/ipnstate"
|
"tailscale.com/ipn/ipnstate"
|
||||||
"tailscale.com/net/interfaces"
|
"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 {
|
func dnsOrQuoteHostname(st *ipnstate.Status, ps *ipnstate.PeerStatus) string {
|
||||||
baseName := dnsname.TrimSuffix(ps.DNSName, st.MagicDNSSuffix)
|
baseName := dnsname.TrimSuffix(ps.DNSName, st.MagicDNSSuffix)
|
||||||
if baseName != "" {
|
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 baseName
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("(%q)", dnsname.SanitizeHostname(ps.HostName))
|
return fmt.Sprintf("(%q)", dnsname.SanitizeHostname(ps.HostName))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user