This change adds Location field to HostInfo.
Location contains the option for a Country, CountryCode, City, CityCode
and a Priority. Neither of these fields are populated by default.
The Priority field is used to determine the priority an exit
node should be given for use, if the field is set. The higher the value
set, the higher priority the node should be given for use.
Updates tailscale/corp#12146
Signed-off-by: Charlotte Brandhorst-Satzkorn <charlotte@tailscale.com>
pull/8432/head
Charlotte Brandhorst-Satzkorn1 year agocommitted byCharlotte Brandhorst-Satzkorn
//go:generate go run tailscale.com/cmd/viewer --type=User,Node,Hostinfo,NetInfo,Login,DNSConfig,RegisterResponse,DERPRegion,DERPMap,DERPNode,SSHRule,SSHAction,SSHPrincipal,ControlDialPlan --clonefunc
//go:generate go run tailscale.com/cmd/viewer --type=User,Node,Hostinfo,NetInfo,Login,DNSConfig,RegisterResponse,DERPRegion,DERPMap,DERPNode,SSHRule,SSHAction,SSHPrincipal,ControlDialPlan,Location --clonefunc
import(
import(
"bytes"
"bytes"
@ -531,6 +531,24 @@ type Service struct {
// TODO(apenwarr): add "tags" here for each service?
// TODO(apenwarr): add "tags" here for each service?
}
}
// Location represents geographical location data about a
// Tailscale host. Location is optional and only set if
// explicitly declared by a node.
typeLocationstruct{
Countrystring`json:",omitempty"`// User friendly country name, with proper capitalization, e.g "Canada"
CountryCodestring`json:",omitempty"`// ISO 3166-1 alpha-2 in lower case, e.g "ca"
Citystring`json:",omitempty"`// User friendly city name, with proper capitalization, e.g. "Squamish"
CityCodestring`json:",omitempty"`
// Priority determines the priority an exit node is given when the
// location data between two or more nodes is tied.
// A higher value indicates that the exit node is more preferable
// for use.
// A value of 0 means the exit node does not have a priority
// preference. A negative int is not allowed.
Priorityint`json:",omitempty"`
}
// Hostinfo contains a summary of a Tailscale host.
// Hostinfo contains a summary of a Tailscale host.
//
//
// Because it contains pointers (slices), this type should not be used
// Because it contains pointers (slices), this type should not be used
@ -585,6 +603,11 @@ type Hostinfo struct {
Userspaceopt.Bool`json:",omitempty"`// if the client is running in userspace (netstack) mode
Userspaceopt.Bool`json:",omitempty"`// if the client is running in userspace (netstack) mode
UserspaceRouteropt.Bool`json:",omitempty"`// if the client's subnet router is running in userspace (netstack) mode
UserspaceRouteropt.Bool`json:",omitempty"`// if the client's subnet router is running in userspace (netstack) mode
// Location represents geographical location data about a
// Tailscale host. Location is optional and only set if
// explicitly declared by a node.
Location*Location`json:",omitempty"`
// NOTE: any new fields containing pointers in this type
// NOTE: any new fields containing pointers in this type
// Clone duplicates src into dst and reports whether it succeeded.
// Clone duplicates src into dst and reports whether it succeeded.
// To succeed, <src, dst> must be of types <*T, *T> or <*T, **T>,
// To succeed, <src, dst> must be of types <*T, *T> or <*T, **T>,
// where T is one of User,Node,Hostinfo,NetInfo,Login,DNSConfig,RegisterResponse,DERPRegion,DERPMap,DERPNode,SSHRule,SSHAction,SSHPrincipal,ControlDialPlan.
// where T is one of User,Node,Hostinfo,NetInfo,Login,DNSConfig,RegisterResponse,DERPRegion,DERPMap,DERPNode,SSHRule,SSHAction,SSHPrincipal,ControlDialPlan,Location.
//go:generate go run tailscale.com/cmd/cloner -clonefunc=true -type=User,Node,Hostinfo,NetInfo,Login,DNSConfig,RegisterResponse,DERPRegion,DERPMap,DERPNode,SSHRule,SSHAction,SSHPrincipal,ControlDialPlan
//go:generate go run tailscale.com/cmd/cloner -clonefunc=true -type=User,Node,Hostinfo,NetInfo,Login,DNSConfig,RegisterResponse,DERPRegion,DERPMap,DERPNode,SSHRule,SSHAction,SSHPrincipal,ControlDialPlan,Location