* show DNS name over hostname, removing domain's common MagicDNS suffix. only show hostname if there's no DNS name. but still show shared devices' MagicDNS FQDN. * remove nerdy low-level details by default: endpoints, DERP relay, public key. They're available in JSON mode still for those who need them. * only show endpoint or DERP relay when it's active with the goal of making debugging easier. (so it's easier for users to understand what's happening) The asterisks are gone. * remove Tx/Rx numbers by default for idle peers; only show them when there's traffic. * include peers' owner login names * add CLI option to not show peers (matching --self=true, --peers= also defaults to true) * sort by DNS/host name, not public key * reorder columnsmain
parent
c09d5a9e28
commit
5efb0a8bca
@ -0,0 +1,19 @@ |
||||
// Copyright (c) 2021 Tailscale Inc & AUTHORS All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package dnsname contains string functions for working with DNS names.
|
||||
package dnsname |
||||
|
||||
import "strings" |
||||
|
||||
// HasSuffix reports whether the provided DNS name ends with the
|
||||
// component(s) in suffix, ignoring any trailing dots.
|
||||
//
|
||||
// If suffix is the empty string, HasSuffix always reports false.
|
||||
func HasSuffix(name, suffix string) bool { |
||||
name = strings.TrimSuffix(name, ".") |
||||
suffix = strings.TrimSuffix(suffix, ".") |
||||
nameBase := strings.TrimSuffix(name, suffix) |
||||
return len(nameBase) < len(name) && strings.HasSuffix(nameBase, ".") |
||||
} |
||||
@ -0,0 +1,28 @@ |
||||
// Copyright (c) 2021 Tailscale Inc & AUTHORS All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package dnsname |
||||
|
||||
import "testing" |
||||
|
||||
func TestHasSuffix(t *testing.T) { |
||||
tests := []struct { |
||||
name, suffix string |
||||
want bool |
||||
}{ |
||||
{"foo.com", "com", true}, |
||||
{"foo.com.", "com", true}, |
||||
{"foo.com.", "com.", true}, |
||||
|
||||
{"", "", false}, |
||||
{"foo.com.", "", false}, |
||||
{"foo.com.", "o.com", false}, |
||||
} |
||||
for _, tt := range tests { |
||||
got := HasSuffix(tt.name, tt.suffix) |
||||
if got != tt.want { |
||||
t.Errorf("HasSuffix(%q, %q) = %v; want %v", tt.name, tt.suffix, got, tt.want) |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue