debugknobs.go 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright (c) Tailscale Inc & AUTHORS
  2. // SPDX-License-Identifier: BSD-3-Clause
  3. //go:build !ios && !js
  4. package magicsock
  5. import (
  6. "tailscale.com/envknob"
  7. )
  8. const linkDebug = true
  9. // Various debugging and experimental tweakables, set by environment
  10. // variable.
  11. var (
  12. // debugDisco prints verbose logs of active discovery events as
  13. // they happen.
  14. debugDisco = envknob.RegisterBool("TS_DEBUG_DISCO")
  15. // debugOmitLocalAddresses removes all local interface addresses
  16. // from magicsock's discovered local endpoints. Used in some tests.
  17. debugOmitLocalAddresses = envknob.RegisterBool("TS_DEBUG_OMIT_LOCAL_ADDRS")
  18. // debugUseDerpRoute temporarily (2020-03-22) controls whether DERP
  19. // reverse routing is enabled (Issue 150).
  20. debugUseDerpRoute = envknob.RegisterOptBool("TS_DEBUG_ENABLE_DERP_ROUTE")
  21. // logDerpVerbose logs all received DERP packets, including their
  22. // full payload.
  23. logDerpVerbose = envknob.RegisterBool("TS_DEBUG_DERP")
  24. // debugReSTUNStopOnIdle unconditionally enables the "shut down
  25. // STUN if magicsock is idle" behavior that normally only triggers
  26. // on mobile devices, lowers the shutdown interval, and logs more
  27. // verbosely about idle measurements.
  28. debugReSTUNStopOnIdle = envknob.RegisterBool("TS_DEBUG_RESTUN_STOP_ON_IDLE")
  29. // debugAlwaysDERP disables the use of UDP, forcing all peer communication over DERP.
  30. debugAlwaysDERP = envknob.RegisterBool("TS_DEBUG_ALWAYS_USE_DERP")
  31. // debugDERPAddr sets the derp address manually, overriding the DERP map from control.
  32. debugUseDERPAddr = envknob.RegisterString("TS_DEBUG_USE_DERP_ADDR")
  33. // debugDERPUseHTTP tells clients to connect to DERP via HTTP on port 3340 instead of
  34. // HTTPS on 443.
  35. debugUseDERPHTTP = envknob.RegisterBool("TS_DEBUG_USE_DERP_HTTP")
  36. // debugEnableSilentDisco disables the use of heartbeatTimer on the endpoint struct
  37. // and attempts to handle disco silently. See issue #540 for details.
  38. debugEnableSilentDisco = envknob.RegisterBool("TS_DEBUG_ENABLE_SILENT_DISCO")
  39. // debugSendCallMeUnknownPeer sends a CallMeMaybe to a non-existent destination every
  40. // time we send a real CallMeMaybe to test the PeerGoneNotHere logic.
  41. debugSendCallMeUnknownPeer = envknob.RegisterBool("TS_DEBUG_SEND_CALLME_UNKNOWN_PEER")
  42. // Hey you! Adding a new debugknob? Make sure to stub it out in the debugknob_stubs.go
  43. // file too.
  44. )
  45. // inTest reports whether the running program is a test that set the
  46. // IN_TS_TEST environment variable.
  47. //
  48. // Unlike the other debug tweakables above, this one needs to be
  49. // checked every time at runtime, because tests set this after program
  50. // startup.
  51. func inTest() bool { return envknob.Bool("IN_TS_TEST") }