Просмотр исходного кода

ipn,tailconfig: clean up unreleased and removed app connector service

This was never released, and is replaced by HostInfo.AppConnector.

Updates tailscale/corp#15437
Signed-off-by: James Tucker <[email protected]>
James Tucker 2 лет назад
Родитель
Сommit
c54d680682
4 измененных файлов с 2 добавлено и 81 удалено
  1. 1 17
      ipn/ipnlocal/local.go
  2. 0 58
      ipn/ipnlocal/local_test.go
  3. 1 1
      ipn/policy/policy.go
  4. 0 5
      tailcfg/tailcfg.go

+ 1 - 17
ipn/ipnlocal/local.go

@@ -3192,12 +3192,6 @@ func (b *LocalBackend) peerAPIServicesLocked() (ret []tailcfg.Service) {
 			Port:  1, // version
 		})
 	}
-	if b.appConnector != nil {
-		ret = append(ret, tailcfg.Service{
-			Proto: tailcfg.AppConnector,
-			Port:  1, // version
-		})
-	}
 	return ret
 }
 
@@ -3278,13 +3272,7 @@ func (b *LocalBackend) reconfigAppConnectorLocked(nm *netmap.NetworkMap, prefs i
 	}()
 
 	if !prefs.AppConnector().Advertise {
-		var old *appc.AppConnector
-		old, b.appConnector = b.appConnector, nil
-		if old != nil {
-			// Ensure that the app connector service will not be advertised now
-			// that b.appConnector is no longer set.
-			go b.doSetHostinfoFilterServices()
-		}
+		b.appConnector = nil
 		return
 	}
 
@@ -3318,10 +3306,6 @@ func (b *LocalBackend) reconfigAppConnectorLocked(nm *netmap.NetworkMap, prefs i
 	slices.Sort(domains)
 	slices.Compact(domains)
 	b.appConnector.UpdateDomains(domains)
-
-	// Ensure that the app connector service will be advertised now that
-	// b.appConnector is set.
-	go b.doSetHostinfoFilterServices()
 }
 
 // authReconfig pushes a new configuration into wgengine, if engine

+ 0 - 58
ipn/ipnlocal/local_test.go

@@ -1157,28 +1157,6 @@ func TestOfferingAppConnector(t *testing.T) {
 	}
 }
 
-func TestAppConnectorHostinfoService(t *testing.T) {
-	hasAppConnectorService := func(s []tailcfg.Service) bool {
-		for _, s := range s {
-			if s.Proto == tailcfg.AppConnector && s.Port == 1 {
-				return true
-			}
-		}
-		return false
-	}
-
-	b := newTestBackend(t)
-	b.mu.Lock()
-	defer b.mu.Unlock()
-	if hasAppConnectorService(b.peerAPIServicesLocked()) {
-		t.Fatal("unexpected app connector service")
-	}
-	b.appConnector = appc.NewAppConnector(t.Logf, nil)
-	if !hasAppConnectorService(b.peerAPIServicesLocked()) {
-		t.Fatal("expected app connector service")
-	}
-}
-
 func TestRouteAdvertiser(t *testing.T) {
 	b := newTestBackend(t)
 	testPrefix := netip.MustParsePrefix("192.0.0.8/32")
@@ -1249,20 +1227,6 @@ func TestReconfigureAppConnector(t *testing.T) {
 	if !slices.Equal(b.appConnector.Domains().AsSlice(), want) {
 		t.Fatalf("got domains %v, want %v", b.appConnector.Domains(), want)
 	}
-
-	// Check that hostinfo has been updated to include the AppConnector service
-	// This is spawned in a goroutine, so may take some attempts to observe
-	var foundAppConnectorService bool
-	for i := 0; i < 10; i++ {
-		foundAppConnectorService = hasAppConnectorService(b)
-		if foundAppConnectorService {
-			break
-		}
-		time.Sleep(10 * time.Millisecond)
-	}
-	if !foundAppConnectorService {
-		t.Fatalf("expected app connector service")
-	}
 	if v, _ := b.hostinfo.AppConnector.Get(); !v {
 		t.Fatalf("expected app connector service")
 	}
@@ -1280,33 +1244,11 @@ func TestReconfigureAppConnector(t *testing.T) {
 	if b.appConnector != nil {
 		t.Fatal("expected no app connector")
 	}
-	// expect the connector service to be removed
-	for i := 0; i < 10; i++ {
-		foundAppConnectorService = hasAppConnectorService(b)
-		if !foundAppConnectorService {
-			break
-		}
-		time.Sleep(10 * time.Millisecond)
-	}
-	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 {
-	b.mu.Lock()
-	defer b.mu.Unlock()
-	for _, s := range b.peerAPIServicesLocked() {
-		if s.Proto == tailcfg.AppConnector && s.Port == 1 {
-			return true
-		}
-	}
-	return false
-}
-
 func resolversEqual(t *testing.T, a, b []*dnstype.Resolver) bool {
 	if a == nil && b == nil {
 		return true

+ 1 - 1
ipn/policy/policy.go

@@ -14,7 +14,7 @@ import (
 // to our peer nodes for discovery purposes.
 func IsInterestingService(s tailcfg.Service, os string) bool {
 	switch s.Proto {
-	case tailcfg.PeerAPI4, tailcfg.PeerAPI6, tailcfg.PeerAPIDNS, tailcfg.AppConnector:
+	case tailcfg.PeerAPI4, tailcfg.PeerAPI6, tailcfg.PeerAPIDNS:
 		return true
 	}
 	if s.Proto != tailcfg.TCP {

+ 0 - 5
tailcfg/tailcfg.go

@@ -629,8 +629,6 @@ const (
 	PeerAPI4   = ServiceProto("peerapi4")
 	PeerAPI6   = ServiceProto("peerapi6")
 	PeerAPIDNS = ServiceProto("peerapi-dns-proxy")
-	// Deprecated: use the field on HostInfo instead.
-	AppConnector = ServiceProto("app-connector")
 )
 
 // Service represents a service running on a node.
@@ -651,9 +649,6 @@ type Service struct {
 	//        being a DNS proxy (when the node is an exit
 	//        node). For this service, the Port number is really
 	//        the version number of the service.
-	//     * "app-connector": (deprecated) the local app-connector
-	//        service is available. For this service, the Port number
-	//        is really the version number of the service.
 	Proto ServiceProto
 
 	// Port is the port number.