debugknobs.go 2.6 KB

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