mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-25 19:15:34 +00:00
tailcfg, ipn, controlclient: add MapResponse.ClientVersion, plumb to IPN bus
Updates #6480 Change-Id: I6321071425cd091148d8140d1eb24dd536bb7984 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
4d3713f631
commit
20b27df4d0
@ -74,8 +74,9 @@ type Direct struct {
|
|||||||
keepSharerAndUserSplit bool
|
keepSharerAndUserSplit bool
|
||||||
skipIPForwardingCheck bool
|
skipIPForwardingCheck bool
|
||||||
pinger Pinger
|
pinger Pinger
|
||||||
popBrowser func(url string) // or nil
|
popBrowser func(url string) // or nil
|
||||||
c2nHandler http.Handler // or nil
|
c2nHandler http.Handler // or nil
|
||||||
|
onClientVersion func(*tailcfg.ClientVersion) // or nil
|
||||||
|
|
||||||
dialPlan ControlDialPlanner // can be nil
|
dialPlan ControlDialPlanner // can be nil
|
||||||
|
|
||||||
@ -109,13 +110,14 @@ type Options struct {
|
|||||||
NewDecompressor func() (Decompressor, error)
|
NewDecompressor func() (Decompressor, error)
|
||||||
KeepAlive bool
|
KeepAlive bool
|
||||||
Logf logger.Logf
|
Logf logger.Logf
|
||||||
HTTPTestClient *http.Client // optional HTTP client to use (for tests only)
|
HTTPTestClient *http.Client // optional HTTP client to use (for tests only)
|
||||||
NoiseTestClient *http.Client // optional HTTP client to use for noise RPCs (tests only)
|
NoiseTestClient *http.Client // optional HTTP client to use for noise RPCs (tests only)
|
||||||
DebugFlags []string // debug settings to send to control
|
DebugFlags []string // debug settings to send to control
|
||||||
LinkMonitor *monitor.Mon // optional link monitor
|
LinkMonitor *monitor.Mon // optional link monitor
|
||||||
PopBrowserURL func(url string) // optional func to open browser
|
PopBrowserURL func(url string) // optional func to open browser
|
||||||
Dialer *tsdial.Dialer // non-nil
|
OnClientVersion func(*tailcfg.ClientVersion) // optional func to inform GUI of client version status
|
||||||
C2NHandler http.Handler // or nil
|
Dialer *tsdial.Dialer // non-nil
|
||||||
|
C2NHandler http.Handler // or nil
|
||||||
|
|
||||||
// Status is called when there's a change in status.
|
// Status is called when there's a change in status.
|
||||||
Status func(Status)
|
Status func(Status)
|
||||||
@ -241,6 +243,7 @@ func NewDirect(opts Options) (*Direct, error) {
|
|||||||
skipIPForwardingCheck: opts.SkipIPForwardingCheck,
|
skipIPForwardingCheck: opts.SkipIPForwardingCheck,
|
||||||
pinger: opts.Pinger,
|
pinger: opts.Pinger,
|
||||||
popBrowser: opts.PopBrowserURL,
|
popBrowser: opts.PopBrowserURL,
|
||||||
|
onClientVersion: opts.OnClientVersion,
|
||||||
c2nHandler: opts.C2NHandler,
|
c2nHandler: opts.C2NHandler,
|
||||||
dialer: opts.Dialer,
|
dialer: opts.Dialer,
|
||||||
dialPlan: opts.DialPlan,
|
dialPlan: opts.DialPlan,
|
||||||
@ -1008,6 +1011,9 @@ func (c *Direct) sendMapRequest(ctx context.Context, maxPolls int, readOnly bool
|
|||||||
c.logf("netmap: control says to open URL %v; no popBrowser func", u)
|
c.logf("netmap: control says to open URL %v; no popBrowser func", u)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if resp.ClientVersion != nil && c.onClientVersion != nil {
|
||||||
|
c.onClientVersion(resp.ClientVersion)
|
||||||
|
}
|
||||||
if resp.ControlTime != nil && !resp.ControlTime.IsZero() {
|
if resp.ControlTime != nil && !resp.ControlTime.IsZero() {
|
||||||
c.logf.JSON(1, "controltime", resp.ControlTime.UTC())
|
c.logf.JSON(1, "controltime", resp.ControlTime.UTC())
|
||||||
}
|
}
|
||||||
|
@ -95,6 +95,10 @@ type Notify struct {
|
|||||||
// macOS Network Extension.
|
// macOS Network Extension.
|
||||||
LocalTCPPort *uint16 `json:",omitempty"`
|
LocalTCPPort *uint16 `json:",omitempty"`
|
||||||
|
|
||||||
|
// ClientVersion, if non-nil, describes whether a client version update
|
||||||
|
// is available.
|
||||||
|
ClientVersion *tailcfg.ClientVersion `json:",omitempty"`
|
||||||
|
|
||||||
// type is mirrored in xcode/Shared/IPN.swift
|
// type is mirrored in xcode/Shared/IPN.swift
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1271,6 +1271,7 @@ func (b *LocalBackend) Start(opts ipn.Options) error {
|
|||||||
LinkMonitor: b.e.GetLinkMonitor(),
|
LinkMonitor: b.e.GetLinkMonitor(),
|
||||||
Pinger: b,
|
Pinger: b,
|
||||||
PopBrowserURL: b.tellClientToBrowseToURL,
|
PopBrowserURL: b.tellClientToBrowseToURL,
|
||||||
|
OnClientVersion: b.onClientVersion,
|
||||||
Dialer: b.Dialer(),
|
Dialer: b.Dialer(),
|
||||||
Status: b.setClientStatus,
|
Status: b.setClientStatus,
|
||||||
C2NHandler: http.HandlerFunc(b.handleC2N),
|
C2NHandler: http.HandlerFunc(b.handleC2N),
|
||||||
@ -1836,6 +1837,21 @@ func (b *LocalBackend) tellClientToBrowseToURL(url string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// onClientVersion is called on MapResponse updates when a MapResponse contains
|
||||||
|
// a non-nil ClientVersion message.
|
||||||
|
func (b *LocalBackend) onClientVersion(v *tailcfg.ClientVersion) {
|
||||||
|
switch runtime.GOOS {
|
||||||
|
case "darwin", "ios":
|
||||||
|
// These auto-update well enough, and we haven't converted the
|
||||||
|
// ClientVersion types to Swift yet, so don't send them in ipn.Notify
|
||||||
|
// messages.
|
||||||
|
default:
|
||||||
|
// But everything else is a Go client and can deal with this field, even
|
||||||
|
// if they ignore it.
|
||||||
|
b.send(ipn.Notify{ClientVersion: v})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// For testing lazy machine key generation.
|
// For testing lazy machine key generation.
|
||||||
var panicOnMachineKeyGeneration = envknob.RegisterBool("TS_DEBUG_PANIC_MACHINE_KEY")
|
var panicOnMachineKeyGeneration = envknob.RegisterBool("TS_DEBUG_PANIC_MACHINE_KEY")
|
||||||
|
|
||||||
|
@ -1425,6 +1425,40 @@ type MapResponse struct {
|
|||||||
// server. An initial nil is equivalent to new(ControlDialPlan).
|
// server. An initial nil is equivalent to new(ControlDialPlan).
|
||||||
// A subsequent streamed nil means no change.
|
// A subsequent streamed nil means no change.
|
||||||
ControlDialPlan *ControlDialPlan `json:",omitempty"`
|
ControlDialPlan *ControlDialPlan `json:",omitempty"`
|
||||||
|
|
||||||
|
// ClientVersion describes the latest client version that's available for
|
||||||
|
// download and whether the client is using it. A nil value means no change
|
||||||
|
// or nothing to report.
|
||||||
|
ClientVersion *ClientVersion `json:",omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClientVersion is information about the latest client version that's available
|
||||||
|
// for the client (and whether they're already running it).
|
||||||
|
//
|
||||||
|
// It does not include a URL to download the client, as that varies by platform.
|
||||||
|
type ClientVersion struct {
|
||||||
|
// RunningLatest is true if the client is running the latest build.
|
||||||
|
RunningLatest bool `json:",omitempty"`
|
||||||
|
|
||||||
|
// LatestVersion is the latest version.Short ("1.34.2") version available
|
||||||
|
// for download for the client's platform and packaging type.
|
||||||
|
// It won't be populated if RunningLatest is true.
|
||||||
|
// The primary purpose of the LatestVersion value is to invalidate the client's
|
||||||
|
// cache update check value, if any. This primarily applies to Windows.
|
||||||
|
LatestVersion string `json:",omitempty"`
|
||||||
|
|
||||||
|
// Notify is whether the client should do an OS-specific notification about
|
||||||
|
// a new version being available. This should not be populated if
|
||||||
|
// RunningLatest is true. The client should not notify multiple times for
|
||||||
|
// the same LatestVersion value.
|
||||||
|
Notify bool `json:",omitempty"`
|
||||||
|
|
||||||
|
// NotifyURL is a URL to open in the browser when the user clicks on the
|
||||||
|
// notification, when Notify is true.
|
||||||
|
NotifyURL string `json:",omitempty"`
|
||||||
|
|
||||||
|
// NotifyText is the text to show in the notification, when Notify is true.
|
||||||
|
NotifyText string `json:",omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ControlDialPlan is instructions from the control server to the client on how
|
// ControlDialPlan is instructions from the control server to the client on how
|
||||||
|
Loading…
Reference in New Issue
Block a user