mirror of
https://github.com/tailscale/tailscale.git
synced 2026-06-11 21:02:39 +08:00
Some checks failed
checklocks / checklocks (push) Has been cancelled
CodeQL / Analyze (go) (push) Has been cancelled
Dockerfile build / deploy (push) Has been cancelled
CI / gomod-cache (push) Has been cancelled
CI / fuzz (push) Has been cancelled
update-flake / update-flake (push) Has been cancelled
CI / race-root-integration (1/4) (push) Has been cancelled
CI / race-root-integration (2/4) (push) Has been cancelled
CI / race-root-integration (3/4) (push) Has been cancelled
CI / race-root-integration (4/4) (push) Has been cancelled
CI / test (-race, amd64, 1/3) (push) Has been cancelled
CI / test (-race, amd64, 2/3) (push) Has been cancelled
CI / test (-race, amd64, 3/3) (push) Has been cancelled
CI / test (386) (push) Has been cancelled
CI / test (amd64) (push) Has been cancelled
CI / Windows (${{ matrix.name || matrix.shard}}) (win-bench, benchmarks) (push) Has been cancelled
CI / Windows (${{ matrix.name || matrix.shard}}) (win-shard-1-2, 1/2) (push) Has been cancelled
CI / Windows (${{ matrix.name || matrix.shard}}) (win-shard-2-2, 2/2) (push) Has been cancelled
CI / Windows (${{ matrix.name || matrix.shard}}) (win-tool-go, ./tool/go) (push) Has been cancelled
CI / privileged (push) Has been cancelled
CI / vm (push) Has been cancelled
CI / cross (386, linux) (push) Has been cancelled
CI / cross (amd64, darwin) (push) Has been cancelled
CI / cross (amd64, freebsd) (push) Has been cancelled
CI / cross (amd64, openbsd) (push) Has been cancelled
CI / cross (amd64, windows) (push) Has been cancelled
CI / cross (arm, 5, linux) (push) Has been cancelled
CI / cross (arm, 7, linux) (push) Has been cancelled
CI / cross (arm64, darwin) (push) Has been cancelled
CI / cross (arm64, linux) (push) Has been cancelled
CI / cross (arm64, windows) (push) Has been cancelled
CI / cross (loong64, linux) (push) Has been cancelled
CI / ios (push) Has been cancelled
CI / crossmin (amd64, illumos) (push) Has been cancelled
CI / crossmin (amd64, plan9) (push) Has been cancelled
CI / crossmin (amd64, solaris) (push) Has been cancelled
CI / crossmin (ppc64, aix) (push) Has been cancelled
CI / android (push) Has been cancelled
CI / wasm (push) Has been cancelled
CI / tailscale_go (push) Has been cancelled
CI / depaware (push) Has been cancelled
CI / go_generate (push) Has been cancelled
CI / go_mod_tidy (push) Has been cancelled
CI / licenses (push) Has been cancelled
CI / staticcheck (${{ matrix.name }}) (--with-tags-all=darwin, arm64, darwin, macOS) (push) Has been cancelled
CI / staticcheck (${{ matrix.name }}) (--with-tags-all=linux, amd64, linux, Linux) (push) Has been cancelled
CI / staticcheck (${{ matrix.name }}) (--with-tags-all=windows, amd64, windows, Windows) (push) Has been cancelled
CI / staticcheck (${{ matrix.name }}) (--without-tags-any=windows,darwin,linux --shard=1/4, amd64, linux, Portable (1/4)) (push) Has been cancelled
CI / staticcheck (${{ matrix.name }}) (--without-tags-any=windows,darwin,linux --shard=2/4, amd64, linux, Portable (2/4)) (push) Has been cancelled
CI / staticcheck (${{ matrix.name }}) (--without-tags-any=windows,darwin,linux --shard=3/4, amd64, linux, Portable (3/4)) (push) Has been cancelled
CI / staticcheck (${{ matrix.name }}) (--without-tags-any=windows,darwin,linux --shard=4/4, amd64, linux, Portable (4/4)) (push) Has been cancelled
CI / notify_slack (push) Has been cancelled
CI / merge_blocker (push) Has been cancelled
CI / check_mergeability_strict (push) Has been cancelled
CI / check_mergeability (push) Has been cancelled
Updates tailscale/corp#30903 Signed-off-by: Jordan Whited <jordan@tailscale.com>
101 lines
4.3 KiB
Go
101 lines
4.3 KiB
Go
// Copyright (c) Tailscale Inc & AUTHORS
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
//go:build !ios && !js
|
|
|
|
package magicsock
|
|
|
|
import (
|
|
"log"
|
|
"net/netip"
|
|
"strings"
|
|
"sync"
|
|
|
|
"tailscale.com/envknob"
|
|
)
|
|
|
|
// Various debugging and experimental tweakables, set by environment
|
|
// variable.
|
|
var (
|
|
// debugDisco prints verbose logs of active discovery events as
|
|
// they happen.
|
|
debugDisco = envknob.RegisterBool("TS_DEBUG_DISCO")
|
|
// debugPeerMap prints verbose logs of changes to the peermap.
|
|
debugPeerMap = envknob.RegisterBool("TS_DEBUG_MAGICSOCK_PEERMAP")
|
|
// debugOmitLocalAddresses removes all local interface addresses
|
|
// from magicsock's discovered local endpoints. Used in some tests.
|
|
debugOmitLocalAddresses = envknob.RegisterBool("TS_DEBUG_OMIT_LOCAL_ADDRS")
|
|
// logDerpVerbose logs all received DERP packets, including their
|
|
// full payload.
|
|
logDerpVerbose = envknob.RegisterBool("TS_DEBUG_DERP")
|
|
// 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.
|
|
debugReSTUNStopOnIdle = envknob.RegisterBool("TS_DEBUG_RESTUN_STOP_ON_IDLE")
|
|
// debugAlwaysDERP disables the use of UDP, forcing all peer communication over DERP.
|
|
debugAlwaysDERP = envknob.RegisterBool("TS_DEBUG_ALWAYS_USE_DERP")
|
|
// 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")
|
|
// 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")
|
|
// debugSendCallMeUnknownPeer sends a CallMeMaybe to a non-existent destination every
|
|
// time we send a real CallMeMaybe to test the PeerGoneNotHere logic.
|
|
debugSendCallMeUnknownPeer = envknob.RegisterBool("TS_DEBUG_SEND_CALLME_UNKNOWN_PEER")
|
|
// 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")
|
|
// debugEnablePMTUD enables the peer MTU feature, which does path MTU
|
|
// discovery on UDP connections between peers. Currently (2023-09-05)
|
|
// this only turns on the don't fragment bit for the magicsock UDP
|
|
// sockets.
|
|
//
|
|
//lint:ignore U1000 used on Linux/Darwin only
|
|
debugEnablePMTUD = envknob.RegisterOptBool("TS_DEBUG_ENABLE_PMTUD")
|
|
// debugPMTUD prints extra debugging about peer MTU path discovery.
|
|
//
|
|
//lint:ignore U1000 used on Linux/Darwin only
|
|
debugPMTUD = envknob.RegisterBool("TS_DEBUG_PMTUD")
|
|
// debugNeverDirectUDP disables the use of direct UDP connections, forcing
|
|
// all peer communication over DERP or peer relay.
|
|
debugNeverDirectUDP = envknob.RegisterBool("TS_DEBUG_NEVER_DIRECT_UDP")
|
|
// Hey you! Adding a new debugknob? Make sure to stub it out in the
|
|
// debugknobs_stubs.go file too.
|
|
)
|
|
|
|
// 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.
|
|
func inTest() bool { return envknob.Bool("IN_TS_TEST") }
|
|
|
|
// pretendpoints returns TS_DEBUG_PRETENDPOINT as []AddrPort, if set.
|
|
// See https://github.com/tailscale/tailscale/issues/12578 and
|
|
// https://github.com/tailscale/tailscale/pull/12735.
|
|
//
|
|
// It can be between 0 and 3 comma-separated AddrPorts.
|
|
var pretendpoints = sync.OnceValue(func() (ret []netip.AddrPort) {
|
|
all := envknob.String("TS_DEBUG_PRETENDPOINT")
|
|
const max = 3
|
|
remain := all
|
|
for remain != "" && len(ret) < max {
|
|
var s string
|
|
s, remain, _ = strings.Cut(remain, ",")
|
|
ap, err := netip.ParseAddrPort(s)
|
|
if err != nil {
|
|
log.Printf("ignoring invalid AddrPort %q in TS_DEBUG_PRETENDPOINT %q: %v", s, all, err)
|
|
continue
|
|
}
|
|
ret = append(ret, ap)
|
|
}
|
|
return
|
|
})
|