tailcfg,ipn/ipnlocal: add hostinfo field to replace service entry

Updates tailscale/corp#15437
Signed-off-by: James Tucker <james@tailscale.com>
This commit is contained in:
James Tucker
2023-11-09 18:00:56 -08:00
committed by James Tucker
parent 1f4a38ed49
commit 0b6636295e
6 changed files with 37 additions and 8 deletions

View File

@@ -1544,6 +1544,7 @@ func (b *LocalBackend) Start(opts ipn.Options) error {
hostinfo.FrontendLogID = opts.FrontendLogID
hostinfo.Userspace.Set(b.sys.IsNetstack())
hostinfo.UserspaceRouter.Set(b.sys.IsNetstackRouter())
hostinfo.AppConnector.Set(b.appConnector != nil)
b.logf.JSON(1, "Hostinfo", hostinfo)
// TODO(apenwarr): avoid the need to reinit controlclient.
@@ -3270,6 +3271,11 @@ func (b *LocalBackend) blockEngineUpdates(block bool) {
// b.mu must be held.
func (b *LocalBackend) reconfigAppConnectorLocked(nm *netmap.NetworkMap, prefs ipn.PrefsView) {
const appConnectorCapName = "tailscale.com/app-connectors"
defer func() {
if b.hostinfo != nil {
b.hostinfo.AppConnector.Set(b.appConnector != nil)
}
}()
if !prefs.AppConnector().Advertise {
var old *appc.AppConnector

View File

@@ -1263,6 +1263,9 @@ func TestReconfigureAppConnector(t *testing.T) {
if !foundAppConnectorService {
t.Fatalf("expected app connector service")
}
if v, _ := b.hostinfo.AppConnector.Get(); !v {
t.Fatalf("expected app connector service")
}
// disable the connector in order to assert that the service is removed
b.EditPrefs(&ipn.MaskedPrefs{
@@ -1288,6 +1291,9 @@ func TestReconfigureAppConnector(t *testing.T) {
if foundAppConnectorService {
t.Fatalf("expected no app connector service")
}
if v, _ := b.hostinfo.AppConnector.Get(); v {
t.Fatalf("expected no app connector service")
}
}
func hasAppConnectorService(b *LocalBackend) bool {