debugknobs.go 1.7 KB

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