tailcfg: add Hostinfo.Userspace{,Router} bits

Change-Id: Iad47f904872f2df146c1f63945f79cfddeac7fe8
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
pull/5504/head
Brad Fitzpatrick 2 years ago committed by Brad Fitzpatrick
parent 9f6c8517e0
commit 761163815c

@ -955,6 +955,8 @@ func (b *LocalBackend) Start(opts ipn.Options) error {
hostinfo := hostinfo.New()
hostinfo.BackendLogID = b.backendLogID
hostinfo.FrontendLogID = opts.FrontendLogID
hostinfo.Userspace.Set(wgengine.IsNetstack(b.e))
hostinfo.UserspaceRouter.Set(wgengine.IsNetstackRouter(b.e))
if b.cc != nil {
// TODO(apenwarr): avoid the need to reinit controlclient.

@ -484,6 +484,8 @@ type Hostinfo struct {
NetInfo *NetInfo `json:",omitempty"`
SSH_HostKeys []string `json:"sshHostKeys,omitempty"` // if advertised
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
// require changes to Hostinfo.Equal.

@ -134,6 +134,8 @@ var _HostinfoCloneNeedsRegeneration = Hostinfo(struct {
NetInfo *NetInfo
SSH_HostKeys []string
Cloud string
Userspace opt.Bool
UserspaceRouter opt.Bool
}{})
// Clone makes a deep copy of NetInfo.

@ -37,6 +37,7 @@ func TestHostinfoEqual(t *testing.T) {
"GoArch", "GoVersion",
"RoutableIPs", "RequestTags",
"Services", "NetInfo", "SSH_HostKeys", "Cloud",
"Userspace", "UserspaceRouter",
}
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",

@ -271,6 +271,8 @@ func (v HostinfoView) Services() views.Slice[Service] { return views.SliceOf(
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) 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.ж) }
// A compilation failure here means this code must be regenerated, with the command at the top of this file.
@ -294,6 +296,8 @@ var _HostinfoViewNeedsRegeneration = Hostinfo(struct {
NetInfo *NetInfo
SSH_HostKeys []string
Cloud string
Userspace opt.Bool
UserspaceRouter opt.Bool
}{})
// View returns a readonly view of NetInfo.

Loading…
Cancel
Save