mirror of
https://github.com/tailscale/tailscale.git
synced 2025-04-09 01:34:39 +00:00
tailcfg: add Hostinfo.Userspace{,Router} bits
Change-Id: Iad47f904872f2df146c1f63945f79cfddeac7fe8 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
9f6c8517e0
commit
761163815c
@ -955,6 +955,8 @@ func (b *LocalBackend) Start(opts ipn.Options) error {
|
|||||||
hostinfo := hostinfo.New()
|
hostinfo := hostinfo.New()
|
||||||
hostinfo.BackendLogID = b.backendLogID
|
hostinfo.BackendLogID = b.backendLogID
|
||||||
hostinfo.FrontendLogID = opts.FrontendLogID
|
hostinfo.FrontendLogID = opts.FrontendLogID
|
||||||
|
hostinfo.Userspace.Set(wgengine.IsNetstack(b.e))
|
||||||
|
hostinfo.UserspaceRouter.Set(wgengine.IsNetstackRouter(b.e))
|
||||||
|
|
||||||
if b.cc != nil {
|
if b.cc != nil {
|
||||||
// TODO(apenwarr): avoid the need to reinit controlclient.
|
// TODO(apenwarr): avoid the need to reinit controlclient.
|
||||||
|
@ -465,25 +465,27 @@ type Service struct {
|
|||||||
// Because it contains pointers (slices), this type should not be used
|
// Because it contains pointers (slices), this type should not be used
|
||||||
// as a value type.
|
// as a value type.
|
||||||
type Hostinfo struct {
|
type Hostinfo struct {
|
||||||
IPNVersion string `json:",omitempty"` // version of this code
|
IPNVersion string `json:",omitempty"` // version of this code
|
||||||
FrontendLogID string `json:",omitempty"` // logtail ID of frontend instance
|
FrontendLogID string `json:",omitempty"` // logtail ID of frontend instance
|
||||||
BackendLogID string `json:",omitempty"` // logtail ID of backend instance
|
BackendLogID string `json:",omitempty"` // logtail ID of backend instance
|
||||||
OS string `json:",omitempty"` // operating system the client runs on (a version.OS value)
|
OS string `json:",omitempty"` // operating system the client runs on (a version.OS value)
|
||||||
OSVersion string `json:",omitempty"` // operating system version, with optional distro prefix ("Debian 10.4", "Windows 10 Pro 10.0.19041")
|
OSVersion string `json:",omitempty"` // operating system version, with optional distro prefix ("Debian 10.4", "Windows 10 Pro 10.0.19041")
|
||||||
Desktop opt.Bool `json:",omitempty"` // if a desktop was detected on Linux
|
Desktop opt.Bool `json:",omitempty"` // if a desktop was detected on Linux
|
||||||
Package string `json:",omitempty"` // Tailscale package to disambiguate ("choco", "appstore", etc; "" for unknown)
|
Package string `json:",omitempty"` // Tailscale package to disambiguate ("choco", "appstore", etc; "" for unknown)
|
||||||
DeviceModel string `json:",omitempty"` // mobile phone model ("Pixel 3a", "iPhone12,3")
|
DeviceModel string `json:",omitempty"` // mobile phone model ("Pixel 3a", "iPhone12,3")
|
||||||
Hostname string `json:",omitempty"` // name of the host the client runs on
|
Hostname string `json:",omitempty"` // name of the host the client runs on
|
||||||
ShieldsUp bool `json:",omitempty"` // indicates whether the host is blocking incoming connections
|
ShieldsUp bool `json:",omitempty"` // indicates whether the host is blocking incoming connections
|
||||||
ShareeNode bool `json:",omitempty"` // indicates this node exists in netmap because it's owned by a shared-to user
|
ShareeNode bool `json:",omitempty"` // indicates this node exists in netmap because it's owned by a shared-to user
|
||||||
GoArch string `json:",omitempty"` // the host's GOARCH value (of the running binary)
|
GoArch string `json:",omitempty"` // the host's GOARCH value (of the running binary)
|
||||||
GoVersion string `json:",omitempty"` // Go version binary was built with
|
GoVersion string `json:",omitempty"` // Go version binary was built with
|
||||||
RoutableIPs []netip.Prefix `json:",omitempty"` // set of IP ranges this client can route
|
RoutableIPs []netip.Prefix `json:",omitempty"` // set of IP ranges this client can route
|
||||||
RequestTags []string `json:",omitempty"` // set of ACL tags this node wants to claim
|
RequestTags []string `json:",omitempty"` // set of ACL tags this node wants to claim
|
||||||
Services []Service `json:",omitempty"` // services advertised by this machine
|
Services []Service `json:",omitempty"` // services advertised by this machine
|
||||||
NetInfo *NetInfo `json:",omitempty"`
|
NetInfo *NetInfo `json:",omitempty"`
|
||||||
SSH_HostKeys []string `json:"sshHostKeys,omitempty"` // if advertised
|
SSH_HostKeys []string `json:"sshHostKeys,omitempty"` // if advertised
|
||||||
Cloud string `json:",omitempty"`
|
Cloud string `json:",omitempty"`
|
||||||
|
Userspace opt.Bool `json:",omitempty"` // if the client is running in userspace (netstack) mode
|
||||||
|
UserspaceRouter opt.Bool `json:",omitempty"` // if the client's subnet router is running in userspace (netstack) mode
|
||||||
|
|
||||||
// NOTE: any new fields containing pointers in this type
|
// NOTE: any new fields containing pointers in this type
|
||||||
// require changes to Hostinfo.Equal.
|
// require changes to Hostinfo.Equal.
|
||||||
|
@ -115,25 +115,27 @@ func (src *Hostinfo) Clone() *Hostinfo {
|
|||||||
|
|
||||||
// A compilation failure here means this code must be regenerated, with the command at the top of this file.
|
// A compilation failure here means this code must be regenerated, with the command at the top of this file.
|
||||||
var _HostinfoCloneNeedsRegeneration = Hostinfo(struct {
|
var _HostinfoCloneNeedsRegeneration = Hostinfo(struct {
|
||||||
IPNVersion string
|
IPNVersion string
|
||||||
FrontendLogID string
|
FrontendLogID string
|
||||||
BackendLogID string
|
BackendLogID string
|
||||||
OS string
|
OS string
|
||||||
OSVersion string
|
OSVersion string
|
||||||
Desktop opt.Bool
|
Desktop opt.Bool
|
||||||
Package string
|
Package string
|
||||||
DeviceModel string
|
DeviceModel string
|
||||||
Hostname string
|
Hostname string
|
||||||
ShieldsUp bool
|
ShieldsUp bool
|
||||||
ShareeNode bool
|
ShareeNode bool
|
||||||
GoArch string
|
GoArch string
|
||||||
GoVersion string
|
GoVersion string
|
||||||
RoutableIPs []netip.Prefix
|
RoutableIPs []netip.Prefix
|
||||||
RequestTags []string
|
RequestTags []string
|
||||||
Services []Service
|
Services []Service
|
||||||
NetInfo *NetInfo
|
NetInfo *NetInfo
|
||||||
SSH_HostKeys []string
|
SSH_HostKeys []string
|
||||||
Cloud string
|
Cloud string
|
||||||
|
Userspace opt.Bool
|
||||||
|
UserspaceRouter opt.Bool
|
||||||
}{})
|
}{})
|
||||||
|
|
||||||
// Clone makes a deep copy of NetInfo.
|
// Clone makes a deep copy of NetInfo.
|
||||||
|
@ -37,6 +37,7 @@ func TestHostinfoEqual(t *testing.T) {
|
|||||||
"GoArch", "GoVersion",
|
"GoArch", "GoVersion",
|
||||||
"RoutableIPs", "RequestTags",
|
"RoutableIPs", "RequestTags",
|
||||||
"Services", "NetInfo", "SSH_HostKeys", "Cloud",
|
"Services", "NetInfo", "SSH_HostKeys", "Cloud",
|
||||||
|
"Userspace", "UserspaceRouter",
|
||||||
}
|
}
|
||||||
if have := fieldsOf(reflect.TypeOf(Hostinfo{})); !reflect.DeepEqual(have, hiHandles) {
|
if have := fieldsOf(reflect.TypeOf(Hostinfo{})); !reflect.DeepEqual(have, hiHandles) {
|
||||||
t.Errorf("Hostinfo.Equal check might be out of sync\nfields: %q\nhandled: %q\n",
|
t.Errorf("Hostinfo.Equal check might be out of sync\nfields: %q\nhandled: %q\n",
|
||||||
|
@ -271,29 +271,33 @@ func (v HostinfoView) Services() views.Slice[Service] { return views.SliceOf(
|
|||||||
func (v HostinfoView) NetInfo() NetInfoView { return v.ж.NetInfo.View() }
|
func (v HostinfoView) NetInfo() NetInfoView { return v.ж.NetInfo.View() }
|
||||||
func (v HostinfoView) SSH_HostKeys() views.Slice[string] { return views.SliceOf(v.ж.SSH_HostKeys) }
|
func (v HostinfoView) SSH_HostKeys() views.Slice[string] { return views.SliceOf(v.ж.SSH_HostKeys) }
|
||||||
func (v HostinfoView) Cloud() string { return v.ж.Cloud }
|
func (v HostinfoView) Cloud() string { return v.ж.Cloud }
|
||||||
|
func (v HostinfoView) Userspace() opt.Bool { return v.ж.Userspace }
|
||||||
|
func (v HostinfoView) UserspaceRouter() opt.Bool { return v.ж.UserspaceRouter }
|
||||||
func (v HostinfoView) Equal(v2 HostinfoView) bool { return v.ж.Equal(v2.ж) }
|
func (v HostinfoView) Equal(v2 HostinfoView) bool { return v.ж.Equal(v2.ж) }
|
||||||
|
|
||||||
// A compilation failure here means this code must be regenerated, with the command at the top of this file.
|
// A compilation failure here means this code must be regenerated, with the command at the top of this file.
|
||||||
var _HostinfoViewNeedsRegeneration = Hostinfo(struct {
|
var _HostinfoViewNeedsRegeneration = Hostinfo(struct {
|
||||||
IPNVersion string
|
IPNVersion string
|
||||||
FrontendLogID string
|
FrontendLogID string
|
||||||
BackendLogID string
|
BackendLogID string
|
||||||
OS string
|
OS string
|
||||||
OSVersion string
|
OSVersion string
|
||||||
Desktop opt.Bool
|
Desktop opt.Bool
|
||||||
Package string
|
Package string
|
||||||
DeviceModel string
|
DeviceModel string
|
||||||
Hostname string
|
Hostname string
|
||||||
ShieldsUp bool
|
ShieldsUp bool
|
||||||
ShareeNode bool
|
ShareeNode bool
|
||||||
GoArch string
|
GoArch string
|
||||||
GoVersion string
|
GoVersion string
|
||||||
RoutableIPs []netip.Prefix
|
RoutableIPs []netip.Prefix
|
||||||
RequestTags []string
|
RequestTags []string
|
||||||
Services []Service
|
Services []Service
|
||||||
NetInfo *NetInfo
|
NetInfo *NetInfo
|
||||||
SSH_HostKeys []string
|
SSH_HostKeys []string
|
||||||
Cloud string
|
Cloud string
|
||||||
|
Userspace opt.Bool
|
||||||
|
UserspaceRouter opt.Bool
|
||||||
}{})
|
}{})
|
||||||
|
|
||||||
// View returns a readonly view of NetInfo.
|
// View returns a readonly view of NetInfo.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user