Skip to content

Commit 228a82f

Browse files
committed
ipn/ipnlocal,tailcfg: add AppConnector service to HostInfo when configured
Updates tailscale/corp#15437 Signed-off-by: James Tucker <james@tailscale.com>
1 parent 6ad54fe commit 228a82f

File tree

4 files changed

+39
-7
lines changed

4 files changed

+39
-7
lines changed

ipn/ipnlocal/local.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3166,6 +3166,12 @@ func (b *LocalBackend) peerAPIServicesLocked() (ret []tailcfg.Service) {
31663166
Port: 1, // version
31673167
})
31683168
}
3169+
if b.appConnector != nil {
3170+
ret = append(ret, tailcfg.Service{
3171+
Proto: tailcfg.AppConnector,
3172+
Port: 1, // version
3173+
})
3174+
}
31693175
return ret
31703176
}
31713177

ipn/ipnlocal/local_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,28 @@ func TestOfferingAppConnector(t *testing.T) {
11571157
}
11581158
}
11591159

1160+
func TestAppConnectorHostinfoService(t *testing.T) {
1161+
hasAppConnectorService := func(s []tailcfg.Service) bool {
1162+
for _, s := range s {
1163+
if s.Proto == tailcfg.AppConnector && s.Port == 1 {
1164+
return true
1165+
}
1166+
}
1167+
return false
1168+
}
1169+
1170+
b := newTestBackend(t)
1171+
b.mu.Lock()
1172+
defer b.mu.Unlock()
1173+
if hasAppConnectorService(b.peerAPIServicesLocked()) {
1174+
t.Fatal("unexpected app connector service")
1175+
}
1176+
b.appConnector = appc.NewEmbeddedAppConnector(t.Logf, nil)
1177+
if !hasAppConnectorService(b.peerAPIServicesLocked()) {
1178+
t.Fatal("expected app connector service")
1179+
}
1180+
}
1181+
11601182
func TestRouteAdvertiser(t *testing.T) {
11611183
b := newTestBackend(t)
11621184
testPrefix := netip.MustParsePrefix("192.0.0.8/32")

ipn/ipnlocal/peerapi.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,7 @@ func dnsQueryForName(name, typStr string) []byte {
10031003
b := dnsmessage.NewBuilder(nil, dnsmessage.Header{
10041004
OpCode: 0, // query
10051005
RecursionDesired: true,
1006-
ID: 0,
1006+
ID: 1, // arbitrary, but 0 is rejected by some servers
10071007
})
10081008
if !strings.HasSuffix(name, ".") {
10091009
name += "."

tailcfg/tailcfg.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -624,11 +624,12 @@ func (h *Hostinfo) CheckRequestTags() error {
624624
type ServiceProto string
625625

626626
const (
627-
TCP = ServiceProto("tcp")
628-
UDP = ServiceProto("udp")
629-
PeerAPI4 = ServiceProto("peerapi4")
630-
PeerAPI6 = ServiceProto("peerapi6")
631-
PeerAPIDNS = ServiceProto("peerapi-dns-proxy")
627+
TCP = ServiceProto("tcp")
628+
UDP = ServiceProto("udp")
629+
PeerAPI4 = ServiceProto("peerapi4")
630+
PeerAPI6 = ServiceProto("peerapi6")
631+
PeerAPIDNS = ServiceProto("peerapi-dns-proxy")
632+
AppConnector = ServiceProto("app-connector")
632633
)
633634

634635
// Service represents a service running on a node.
@@ -645,10 +646,13 @@ type Service struct {
645646
// * "peerapi6": peerapi is available on IPv6; Port is the
646647
// port number that the peerapi is running on the
647648
// node's Tailscale IPv6 address.
648-
// * "peerapi-dns": the local peerapi service supports
649+
// * "peerapi-dns-proxy": the local peerapi service supports
649650
// being a DNS proxy (when the node is an exit
650651
// node). For this service, the Port number is really
651652
// the version number of the service.
653+
// * "app-connector": the local app-connector service is
654+
// available. For this service, the Port number is
655+
// really the version number of the service.
652656
Proto ServiceProto
653657

654658
// Port is the port number.

0 commit comments

Comments
 (0)