mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-05 20:13:44 +02:00
A little more clarity to locator display.
This commit is contained in:
parent
441f4986ac
commit
d7e4404c17
2 changed files with 29 additions and 2 deletions
|
@ -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())
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Reference in a new issue