tailcfg, control/controlclient: add method to exit client from control plane

Change-Id: Ic28ef283ba63396b68fab86bfb0a8ee8f432474c
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick 2021-11-01 11:50:46 -07:00 committed by Brad Fitzpatrick
parent 0303ec44c3
commit ff597e773e
3 changed files with 12 additions and 3 deletions

View File

@ -765,6 +765,10 @@ func (c *Direct) sendMapRequest(ctx context.Context, maxPolls int, cb func(*netm
// being conservative here, if Debug not present set to False
controlknobs.SetDisableUPnP(hasDebug && resp.Debug.DisableUPnP.EqualBool(true))
if hasDebug {
if code := resp.Debug.Exit; code != nil {
c.logf("exiting process with status %v per controlplane", *code)
os.Exit(*code)
}
if resp.Debug.LogHeapPprof {
go logheap.LogHeap(resp.Debug.LogHeapURL)
}

View File

@ -48,7 +48,8 @@ import (
// 22: 2021-06-16: added MapResponse.DNSConfig.ExtraRecords
// 23: 2021-08-25: DNSConfig.Routes values may be empty (for ExtraRecords support in 1.14.1+)
// 24: 2021-09-18: MapResponse.Health from control to node; node shows in "tailscale status"
const CurrentMapRequestVersion = 24
// 25: 2021-11-01: MapResponse.Debug.Exit
const CurrentMapRequestVersion = 25
type StableID string
@ -1119,12 +1120,16 @@ type Debug struct {
// fixed port.
RandomizeClientPort bool `json:",omitempty"`
/// DisableUPnP is whether the client will attempt to perform a UPnP portmapping.
// DisableUPnP is whether the client will attempt to perform a UPnP portmapping.
// By default, we want to enable it to see if it works on more clients.
//
// If UPnP catastrophically fails for people, this should be set to True to kill
// new attempts at UPnP connections.
DisableUPnP opt.Bool `json:",omitempty"`
// Exit optionally specifies that the client should os.Exit
// with this code.
Exit *int `json:",omitempty"`
}
func appendKey(base []byte, prefix string, k [32]byte) []byte {

View File

@ -14,7 +14,7 @@ import (
// Long is a full version number for this build, of the form
// "x.y.z-commithash", or "date.yyyymmdd" if no actual version was
// provided.
var Long = "date.20211022"
var Long = "date.20211101"
// Short is a short version number for this build, of the form
// "x.y.z", or "date.yyyymmdd" if no actual version was provided.