2023-01-27 21:37:20 +00:00
|
|
|
// Copyright (c) Tailscale Inc & AUTHORS
|
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
2021-08-15 20:20:44 +00:00
|
|
|
|
2022-06-06 20:52:52 +00:00
|
|
|
//go:build !ios && !js
|
2021-08-15 20:20:44 +00:00
|
|
|
|
|
|
|
package magicsock
|
|
|
|
|
|
|
|
import (
|
2022-01-24 18:52:57 +00:00
|
|
|
"tailscale.com/envknob"
|
2021-08-15 20:20:44 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Various debugging and experimental tweakables, set by environment
|
|
|
|
// variable.
|
|
|
|
var (
|
|
|
|
// debugDisco prints verbose logs of active discovery events as
|
|
|
|
// they happen.
|
2022-09-14 19:49:39 +00:00
|
|
|
debugDisco = envknob.RegisterBool("TS_DEBUG_DISCO")
|
2021-08-15 20:20:44 +00:00
|
|
|
// debugOmitLocalAddresses removes all local interface addresses
|
|
|
|
// from magicsock's discovered local endpoints. Used in some tests.
|
2022-09-14 19:49:39 +00:00
|
|
|
debugOmitLocalAddresses = envknob.RegisterBool("TS_DEBUG_OMIT_LOCAL_ADDRS")
|
2021-08-15 20:20:44 +00:00
|
|
|
// debugUseDerpRoute temporarily (2020-03-22) controls whether DERP
|
2022-01-24 18:52:57 +00:00
|
|
|
// reverse routing is enabled (Issue 150).
|
2022-09-14 19:49:39 +00:00
|
|
|
debugUseDerpRoute = envknob.RegisterOptBool("TS_DEBUG_ENABLE_DERP_ROUTE")
|
2021-08-15 20:20:44 +00:00
|
|
|
// logDerpVerbose logs all received DERP packets, including their
|
|
|
|
// full payload.
|
2022-09-14 19:49:39 +00:00
|
|
|
logDerpVerbose = envknob.RegisterBool("TS_DEBUG_DERP")
|
2021-08-15 20:20:44 +00:00
|
|
|
// debugReSTUNStopOnIdle unconditionally enables the "shut down
|
|
|
|
// STUN if magicsock is idle" behavior that normally only triggers
|
|
|
|
// on mobile devices, lowers the shutdown interval, and logs more
|
|
|
|
// verbosely about idle measurements.
|
2022-09-14 19:49:39 +00:00
|
|
|
debugReSTUNStopOnIdle = envknob.RegisterBool("TS_DEBUG_RESTUN_STOP_ON_IDLE")
|
2021-08-15 20:20:44 +00:00
|
|
|
// debugAlwaysDERP disables the use of UDP, forcing all peer communication over DERP.
|
2022-09-14 19:49:39 +00:00
|
|
|
debugAlwaysDERP = envknob.RegisterBool("TS_DEBUG_ALWAYS_USE_DERP")
|
2023-04-05 00:10:50 +00:00
|
|
|
// debugDERPAddr sets the derp address manually, overriding the DERP map from control.
|
|
|
|
debugUseDERPAddr = envknob.RegisterString("TS_DEBUG_USE_DERP_ADDR")
|
|
|
|
// debugDERPUseHTTP tells clients to connect to DERP via HTTP on port 3340 instead of
|
|
|
|
// HTTPS on 443.
|
|
|
|
debugUseDERPHTTP = envknob.RegisterBool("TS_DEBUG_USE_DERP_HTTP")
|
2022-09-17 03:48:46 +00:00
|
|
|
// debugEnableSilentDisco disables the use of heartbeatTimer on the endpoint struct
|
|
|
|
// and attempts to handle disco silently. See issue #540 for details.
|
|
|
|
debugEnableSilentDisco = envknob.RegisterBool("TS_DEBUG_ENABLE_SILENT_DISCO")
|
2023-04-05 00:10:50 +00:00
|
|
|
// debugSendCallMeUnknownPeer sends a CallMeMaybe to a non-existent destination every
|
|
|
|
// time we send a real CallMeMaybe to test the PeerGoneNotHere logic.
|
2023-03-25 02:11:48 +00:00
|
|
|
debugSendCallMeUnknownPeer = envknob.RegisterBool("TS_DEBUG_SEND_CALLME_UNKNOWN_PEER")
|
2023-07-26 20:59:42 +00:00
|
|
|
// debugBindSocket prints extra debugging about socket rebinding in magicsock.
|
|
|
|
debugBindSocket = envknob.RegisterBool("TS_DEBUG_MAGICSOCK_BIND_SOCKET")
|
|
|
|
// debugRingBufferMaxSizeBytes overrides the default size of the endpoint
|
|
|
|
// history ringbuffer.
|
|
|
|
debugRingBufferMaxSizeBytes = envknob.RegisterInt("TS_DEBUG_MAGICSOCK_RING_BUFFER_MAX_SIZE_BYTES")
|
2023-08-11 08:34:51 +00:00
|
|
|
// debugPMTUD enables path MTU discovery. Currently only sets the Don't Fragment sockopt.
|
|
|
|
debugPMTUD = envknob.RegisterBool("TS_DEBUG_ENABLE_PMTUD")
|
2023-04-05 00:10:50 +00:00
|
|
|
// Hey you! Adding a new debugknob? Make sure to stub it out in the debugknob_stubs.go
|
|
|
|
// file too.
|
2021-08-15 20:20:44 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// inTest reports whether the running program is a test that set the
|
|
|
|
// IN_TS_TEST environment variable.
|
|
|
|
//
|
|
|
|
// Unlike the other debug tweakables above, this one needs to be
|
|
|
|
// checked every time at runtime, because tests set this after program
|
|
|
|
// startup.
|
2022-01-24 18:52:57 +00:00
|
|
|
func inTest() bool { return envknob.Bool("IN_TS_TEST") }
|