diff --git a/cmd/zerotier/cli/locator.go b/cmd/zerotier/cli/locator.go index b924b12a3..5d2f85334 100644 --- a/cmd/zerotier/cli/locator.go +++ b/cmd/zerotier/cli/locator.go @@ -71,9 +71,9 @@ func Locator(args []string) int { return 1 } loc := cliGetLocatorOrFatal(args[1]) - fmt.Printf("%s %s\n",loc.Fingerprint.Address.String(),loc.Fingerprint.String()) + fmt.Printf("%s fingerprint %s\n",loc.Fingerprint.Address.String(),loc.Fingerprint.String()) for _, e := range loc.Endpoints { - fmt.Printf("\t%s\n",e.String()) + fmt.Printf("\tendpoint %s type %s\n",e.String(),e.TypeString()) } } diff --git a/pkg/zerotier/endpoint.go b/pkg/zerotier/endpoint.go index bac5a8d25..42bc74e8c 100644 --- a/pkg/zerotier/endpoint.go +++ b/pkg/zerotier/endpoint.go @@ -42,6 +42,28 @@ type Endpoint struct { cep C.ZT_Endpoint } +func EndpointTypeToString(int t) string { + switch t { + case EndpointTypeZeroTier: + return "zerotier" + case EndpointTypeEthernet: + return "ethernet" + case EndpointTypeWifiDirect: + return "wifi-direct" + case EndpointTypeBluetooth: + return "bluetooth" + case EndpointTypeIp: + return "ip/raw" + case EndpointTypeIpUdp: + return "ip/udp" + case EndpointTypeIpTcp: + return "ip/tcp" + case EndpointTypeIpHttp: + return "ip/http" + } + return "unsupported" +} + // NewEndpointFromString constructs a new endpoint from an InetAddress or Endpoint string. // This will auto detect whether this is a plain InetAddress or an Endpoint in string // format. If the former it's created as a ZT_ENDPOINT_TYPE_IP_UDP endpoint. @@ -76,6 +98,11 @@ func (ep *Endpoint) Type() int { return int(ep.cep._type) } +// TypeString returns a human-readable endpoint type. +func (ep *Endpoint) TypeString() string { + return EndpointTypeToString(int(ep.cep._type)) +} + // InetAddress gets this Endpoint as an InetAddress or nil if its type is not addressed by one. func (ep *Endpoint) InetAddress() *InetAddress { switch ep.cep._type {