From 96d806789fb3a3a634840d0aaef721f09f99b2ce Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Thu, 9 Jul 2020 09:08:54 -0700 Subject: [PATCH] ipn: add Notify.LocalTCPPort field for macOS Network Extension to use We want the macOS Network Extension to share fate with the UI frontend, so we need the backend to know when the frontend disappears. One easy way to do that is to reuse the existing TCP server it's already running (for tailscale status clietns). We now tell the frontend our ephemeral TCP port number, and then have the UI connect to it, so the backend can know when it disappears. There are likely Swift ways of doing this, but I couldn't find them quickly enough, so I reached for the hammer I knew. --- ipn/backend.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ipn/backend.go b/ipn/backend.go index f717eab81..29f7daaaf 100644 --- a/ipn/backend.go +++ b/ipn/backend.go @@ -58,6 +58,12 @@ type Notify struct { BrowseToURL *string // UI should open a browser right now BackendLogID *string // public logtail id used by backend + // LocalTCPPort, if non-nil, informs the UI frontend which + // (non-zero) localhost TCP port it's listening on. + // This is currently only used by Tailscale when run in the + // macOS Network Extension. + LocalTCPPort *uint16 `json:",omitempty"` + // type is mirrored in xcode/Shared/IPN.swift }