2
0

debugknobs.go 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. // debugPeerMap prints verbose logs of changes to the peermap.
  15. debugPeerMap = envknob.RegisterBool("TS_DEBUG_MAGICSOCK_PEERMAP")
  16. // debugOmitLocalAddresses removes all local interface addresses
  17. // from magicsock's discovered local endpoints. Used in some tests.
  18. debugOmitLocalAddresses = envknob.RegisterBool("TS_DEBUG_OMIT_LOCAL_ADDRS")
  19. // logDerpVerbose logs all received DERP packets, including their
  20. // full payload.
  21. logDerpVerbose = envknob.RegisterBool("TS_DEBUG_DERP")
  22. // debugReSTUNStopOnIdle unconditionally enables the "shut down
  23. // STUN if magicsock is idle" behavior that normally only triggers
  24. // on mobile devices, lowers the shutdown interval, and logs more
  25. // verbosely about idle measurements.
  26. debugReSTUNStopOnIdle = envknob.RegisterBool("TS_DEBUG_RESTUN_STOP_ON_IDLE")
  27. // debugAlwaysDERP disables the use of UDP, forcing all peer communication over DERP.
  28. debugAlwaysDERP = envknob.RegisterBool("TS_DEBUG_ALWAYS_USE_DERP")
  29. // debugDERPAddr sets the derp address manually, overriding the DERP map from control.
  30. debugUseDERPAddr = envknob.RegisterString("TS_DEBUG_USE_DERP_ADDR")
  31. // debugDERPUseHTTP tells clients to connect to DERP via HTTP on port 3340 instead of
  32. // HTTPS on 443.
  33. debugUseDERPHTTP = envknob.RegisterBool("TS_DEBUG_USE_DERP_HTTP")
  34. // debugEnableSilentDisco disables the use of heartbeatTimer on the endpoint struct
  35. // and attempts to handle disco silently. See issue #540 for details.
  36. debugEnableSilentDisco = envknob.RegisterBool("TS_DEBUG_ENABLE_SILENT_DISCO")
  37. // debugSendCallMeUnknownPeer sends a CallMeMaybe to a non-existent destination every
  38. // time we send a real CallMeMaybe to test the PeerGoneNotHere logic.
  39. debugSendCallMeUnknownPeer = envknob.RegisterBool("TS_DEBUG_SEND_CALLME_UNKNOWN_PEER")
  40. // debugBindSocket prints extra debugging about socket rebinding in magicsock.
  41. debugBindSocket = envknob.RegisterBool("TS_DEBUG_MAGICSOCK_BIND_SOCKET")
  42. // debugRingBufferMaxSizeBytes overrides the default size of the endpoint
  43. // history ringbuffer.
  44. debugRingBufferMaxSizeBytes = envknob.RegisterInt("TS_DEBUG_MAGICSOCK_RING_BUFFER_MAX_SIZE_BYTES")
  45. // debugEnablePMTUD enables the peer MTU feature, which does path MTU
  46. // discovery on UDP connections between peers. Currently (2023-09-05)
  47. // this only turns on the don't fragment bit for the magicsock UDP
  48. // sockets.
  49. //
  50. //lint:ignore U1000 used on Linux/Darwin only
  51. debugEnablePMTUD = envknob.RegisterOptBool("TS_DEBUG_ENABLE_PMTUD")
  52. // debugPMTUD prints extra debugging about peer MTU path discovery.
  53. //
  54. //lint:ignore U1000 used on Linux/Darwin only
  55. debugPMTUD = envknob.RegisterBool("TS_DEBUG_PMTUD")
  56. // Hey you! Adding a new debugknob? Make sure to stub it out in the
  57. // debugknobs_stubs.go file too.
  58. )
  59. // inTest reports whether the running program is a test that set the
  60. // IN_TS_TEST environment variable.
  61. //
  62. // Unlike the other debug tweakables above, this one needs to be
  63. // checked every time at runtime, because tests set this after program
  64. // startup.
  65. func inTest() bool { return envknob.Bool("IN_TS_TEST") }