debugknobs.go 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright (c) 2021 Tailscale Inc & AUTHORS All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. //go:build !ios && !js
  5. // +build !ios,!js
  6. package magicsock
  7. import (
  8. "tailscale.com/envknob"
  9. )
  10. const linkDebug = true
  11. // Various debugging and experimental tweakables, set by environment
  12. // variable.
  13. var (
  14. // debugDisco prints verbose logs of active discovery events as
  15. // they happen.
  16. debugDisco = envknob.RegisterBool("TS_DEBUG_DISCO")
  17. // debugOmitLocalAddresses removes all local interface addresses
  18. // from magicsock's discovered local endpoints. Used in some tests.
  19. debugOmitLocalAddresses = envknob.RegisterBool("TS_DEBUG_OMIT_LOCAL_ADDRS")
  20. // debugUseDerpRoute temporarily (2020-03-22) controls whether DERP
  21. // reverse routing is enabled (Issue 150).
  22. debugUseDerpRoute = envknob.RegisterOptBool("TS_DEBUG_ENABLE_DERP_ROUTE")
  23. // logDerpVerbose logs all received DERP packets, including their
  24. // full payload.
  25. logDerpVerbose = envknob.RegisterBool("TS_DEBUG_DERP")
  26. // debugReSTUNStopOnIdle unconditionally enables the "shut down
  27. // STUN if magicsock is idle" behavior that normally only triggers
  28. // on mobile devices, lowers the shutdown interval, and logs more
  29. // verbosely about idle measurements.
  30. debugReSTUNStopOnIdle = envknob.RegisterBool("TS_DEBUG_RESTUN_STOP_ON_IDLE")
  31. // debugAlwaysDERP disables the use of UDP, forcing all peer communication over DERP.
  32. debugAlwaysDERP = envknob.RegisterBool("TS_DEBUG_ALWAYS_USE_DERP")
  33. )
  34. // inTest reports whether the running program is a test that set the
  35. // IN_TS_TEST environment variable.
  36. //
  37. // Unlike the other debug tweakables above, this one needs to be
  38. // checked every time at runtime, because tests set this after program
  39. // startup.
  40. func inTest() bool { return envknob.Bool("IN_TS_TEST") }