mirror of
https://github.com/tailscale/tailscale.git
synced 2025-06-13 03:09:20 +00:00
control/controlclient: remove misleading TS_DEBUG_NETMAP, make it TS_DEBUG_MAP=2 (or more)
Updates #cleanup Change-Id: Ic1edaed46b7b451ab58bb2303640225223eba9ce Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
2fc4455e6d
commit
27477983e3
@ -650,7 +650,7 @@ func (c *Direct) doLogin(ctx context.Context, opt loginOpt) (mustRegen bool, new
|
|||||||
c.logf("RegisterReq sign error: %v", err)
|
c.logf("RegisterReq sign error: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if debugRegister() {
|
if DevKnob.DumpRegister() {
|
||||||
j, _ := json.MarshalIndent(request, "", "\t")
|
j, _ := json.MarshalIndent(request, "", "\t")
|
||||||
c.logf("RegisterRequest: %s", j)
|
c.logf("RegisterRequest: %s", j)
|
||||||
}
|
}
|
||||||
@ -691,7 +691,7 @@ func (c *Direct) doLogin(ctx context.Context, opt loginOpt) (mustRegen bool, new
|
|||||||
c.logf("error decoding RegisterResponse with server key %s and machine key %s: %v", serverKey, machinePrivKey.Public(), err)
|
c.logf("error decoding RegisterResponse with server key %s and machine key %s: %v", serverKey, machinePrivKey.Public(), err)
|
||||||
return regen, opt.URL, nil, fmt.Errorf("register request: %v", err)
|
return regen, opt.URL, nil, fmt.Errorf("register request: %v", err)
|
||||||
}
|
}
|
||||||
if debugRegister() {
|
if DevKnob.DumpRegister() {
|
||||||
j, _ := json.MarshalIndent(resp, "", "\t")
|
j, _ := json.MarshalIndent(resp, "", "\t")
|
||||||
c.logf("RegisterResponse: %s", j)
|
c.logf("RegisterResponse: %s", j)
|
||||||
}
|
}
|
||||||
@ -877,7 +877,7 @@ func (c *Direct) sendMapRequest(ctx context.Context, isStreaming bool, nu Netmap
|
|||||||
c.logf("[v1] PollNetMap: stream=%v ep=%v", isStreaming, epStrs)
|
c.logf("[v1] PollNetMap: stream=%v ep=%v", isStreaming, epStrs)
|
||||||
|
|
||||||
vlogf := logger.Discard
|
vlogf := logger.Discard
|
||||||
if DevKnob.DumpNetMaps() {
|
if DevKnob.DumpNetMapsVerbose() {
|
||||||
// TODO(bradfitz): update this to use "[v2]" prefix perhaps? but we don't
|
// TODO(bradfitz): update this to use "[v2]" prefix perhaps? but we don't
|
||||||
// want to upload it always.
|
// want to upload it always.
|
||||||
vlogf = c.logf
|
vlogf = c.logf
|
||||||
@ -1170,11 +1170,6 @@ func decode(res *http.Response, v any) error {
|
|||||||
return json.Unmarshal(msg, v)
|
return json.Unmarshal(msg, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
|
||||||
debugMap = envknob.RegisterBool("TS_DEBUG_MAP")
|
|
||||||
debugRegister = envknob.RegisterBool("TS_DEBUG_REGISTER")
|
|
||||||
)
|
|
||||||
|
|
||||||
var jsonEscapedZero = []byte(`\u0000`)
|
var jsonEscapedZero = []byte(`\u0000`)
|
||||||
|
|
||||||
// decodeMsg is responsible for uncompressing msg and unmarshaling into v.
|
// decodeMsg is responsible for uncompressing msg and unmarshaling into v.
|
||||||
@ -1183,7 +1178,7 @@ func (c *Direct) decodeMsg(compressedMsg []byte, v any) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if debugMap() {
|
if DevKnob.DumpNetMaps() {
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
json.Indent(&buf, b, "", " ")
|
json.Indent(&buf, b, "", " ")
|
||||||
log.Printf("MapResponse: %s", buf.Bytes())
|
log.Printf("MapResponse: %s", buf.Bytes())
|
||||||
@ -1205,7 +1200,7 @@ func encode(v any) ([]byte, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if debugMap() {
|
if DevKnob.DumpNetMaps() {
|
||||||
if _, ok := v.(*tailcfg.MapRequest); ok {
|
if _, ok := v.(*tailcfg.MapRequest); ok {
|
||||||
log.Printf("MapRequest: %s", b)
|
log.Printf("MapRequest: %s", b)
|
||||||
}
|
}
|
||||||
@ -1253,18 +1248,23 @@ func loadServerPubKeys(ctx context.Context, httpc *http.Client, serverURL string
|
|||||||
var DevKnob = initDevKnob()
|
var DevKnob = initDevKnob()
|
||||||
|
|
||||||
type devKnobs struct {
|
type devKnobs struct {
|
||||||
DumpNetMaps func() bool
|
DumpRegister func() bool
|
||||||
ForceProxyDNS func() bool
|
DumpNetMaps func() bool
|
||||||
StripEndpoints func() bool // strip endpoints from control (only use disco messages)
|
DumpNetMapsVerbose func() bool
|
||||||
StripCaps func() bool // strip all local node's control-provided capabilities
|
ForceProxyDNS func() bool
|
||||||
|
StripEndpoints func() bool // strip endpoints from control (only use disco messages)
|
||||||
|
StripCaps func() bool // strip all local node's control-provided capabilities
|
||||||
}
|
}
|
||||||
|
|
||||||
func initDevKnob() devKnobs {
|
func initDevKnob() devKnobs {
|
||||||
|
nm := envknob.RegisterInt("TS_DEBUG_MAP")
|
||||||
return devKnobs{
|
return devKnobs{
|
||||||
DumpNetMaps: envknob.RegisterBool("TS_DEBUG_NETMAP"),
|
DumpNetMaps: func() bool { return nm() > 0 },
|
||||||
ForceProxyDNS: envknob.RegisterBool("TS_DEBUG_PROXY_DNS"),
|
DumpNetMapsVerbose: func() bool { return nm() > 1 },
|
||||||
StripEndpoints: envknob.RegisterBool("TS_DEBUG_STRIP_ENDPOINTS"),
|
DumpRegister: envknob.RegisterBool("TS_DEBUG_REGISTER"),
|
||||||
StripCaps: envknob.RegisterBool("TS_DEBUG_STRIP_CAPS"),
|
ForceProxyDNS: envknob.RegisterBool("TS_DEBUG_PROXY_DNS"),
|
||||||
|
StripEndpoints: envknob.RegisterBool("TS_DEBUG_STRIP_ENDPOINTS"),
|
||||||
|
StripCaps: envknob.RegisterBool("TS_DEBUG_STRIP_CAPS"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user