debugknobs.go 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. // debugEnableSilentDisco disables the use of heartbeatTimer on the endpoint struct
  32. // and attempts to handle disco silently. See issue #540 for details.
  33. debugEnableSilentDisco = envknob.RegisterBool("TS_DEBUG_ENABLE_SILENT_DISCO")
  34. // DebugSendCallMeUnknownPeer sends a CallMeMaybe to a
  35. // non-existent destination every time we send a real
  36. // CallMeMaybe to test the PeerGoneNotHere logic.
  37. debugSendCallMeUnknownPeer = envknob.RegisterBool("TS_DEBUG_SEND_CALLME_UNKNOWN_PEER")
  38. )
  39. // inTest reports whether the running program is a test that set the
  40. // IN_TS_TEST environment variable.
  41. //
  42. // Unlike the other debug tweakables above, this one needs to be
  43. // checked every time at runtime, because tests set this after program
  44. // startup.
  45. func inTest() bool { return envknob.Bool("IN_TS_TEST") }