envknob

package
v1.48.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 21, 2023 License: BSD-3-Clause Imports: 16 Imported by: 128

Documentation

Overview

Package envknob provides access to environment-variable tweakable debug settings.

These are primarily knobs used by Tailscale developers during development or by users when instructed to by Tailscale developers when debugging something. They are not a stable interface and may be removed or any time.

A related package, control/controlknobs, are knobs that can be changed at runtime by the control plane. Sometimes both are used: an envknob for the default/explicit value, else falling back to the controlknob value.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllowsRemoteUpdate added in v1.36.0

func AllowsRemoteUpdate() bool

AllowsRemoteUpdate reports whether this node has opted-in to letting the Tailscale control plane initiate a Tailscale update (e.g. on behalf of an admin on the admin console).

func ApplyDiskConfig added in v1.32.0

func ApplyDiskConfig() (err error)

ApplyDiskConfig returns a platform-specific config file of environment keys/values and applies them. On Linux and Unix operating systems, it's a no-op and always returns nil. If no platform-specific config file is found, it also returns nil.

It exists primarily for Windows and macOS to make it easy to apply environment variables to a running service in a way similar to modifying /etc/default/tailscaled on Linux.

On Windows, you use %ProgramData%\Tailscale\tailscaled-env.txt instead.

On macOS, use one of:

  • ~/Library/Containers/io.tailscale.ipn.macsys/Data/tailscaled-env.txt for standalone macOS GUI builds
  • ~/Library/Containers/io.tailscale.ipn.macos.network-extension/Data/tailscaled-env.txt for App Store builds
  • /etc/tailscale/tailscaled-env.txt for tailscaled-on-macOS (homebrew, etc)

func ApplyDiskConfigError added in v1.32.0

func ApplyDiskConfigError() error

ApplyDiskConfigError returns the most recent result of ApplyDiskConfig.

func Bool

func Bool(envVar string) bool

Bool returns the boolean value of the named environment variable. If the variable is not set, it returns false. An invalid value exits the binary with a failure.

func BoolDefaultTrue

func BoolDefaultTrue(envVar string) bool

BoolDefaultTrue is like Bool, but returns true by default if the environment variable isn't present.

func CanSSHD added in v1.24.0

func CanSSHD() bool

CanSSHD reports whether the Tailscale SSH server is allowed to run.

If disabled (when this reports false), the SSH server won't start (won't intercept port 22) if previously configured to do so and any attempt to re-enable it will result in an error.

func CanTaildrop added in v1.34.0

func CanTaildrop() bool

CanTaildrop reports whether the Taildrop feature is allowed to function.

If disabled, Taildrop won't receive files regardless of user & server config.

func GOOS added in v1.34.0

func GOOS() string

GOOS reports the effective runtime.GOOS to run as.

In practice this returns just runtime.GOOS, unless overridden by test TS_DEBUG_FAKE_GOOS.

This allows changing OS-specific stuff like the IPN server behavior for tests so we can e.g. test Windows-specific behaviors on Linux. This isn't universally used.

func IPCVersion added in v1.34.0

func IPCVersion() string

IPCVersion returns version.Long usually, unless TS_DEBUG_FAKE_IPC_VERSION is set, in which it contains that value. This is only used for weird development cases when testing mismatched versions and you want the client to act like it's compatible with the server.

func LogCurrent

func LogCurrent(logf logf)

LogCurrent logs the currently set environment knobs.

func LookupBool

func LookupBool(envVar string) (v bool, ok bool)

LookupBool returns the boolean value of the named environment value. The ok result is whether a value was set. If the value isn't a valid int, it exits the program with a failure.

func LookupInt

func LookupInt(envVar string) (v int, ok bool)

LookupInt returns the integer value of the named environment value. The ok result is whether a value was set. If the value isn't a valid int, it exits the program with a failure.

func LookupIntSized added in v1.40.0

func LookupIntSized(envVar string, base, bitSize int) (v int, ok bool)

LookupIntSized returns the integer value of the named environment value parsed in base and with a maximum bit size bitSize. The ok result is whether a value was set. If the value isn't a valid int, it exits the program with a failure.

func LookupUintSized added in v1.40.0

func LookupUintSized(envVar string, base, bitSize int) (v uint, ok bool)

LookupUintSized returns the unsigned integer value of the named environment value parsed in base and with a maximum bit size bitSize. The ok result is whether a value was set. If the value isn't a valid int, it exits the program with a failure.

func NoLogsNoSupport added in v1.32.0

func NoLogsNoSupport() bool

NoLogsNoSupport reports whether the client's opted out of log uploads and technical support.

func OptBool

func OptBool(envVar string) opt.Bool

OptBool is like Bool, but returns an opt.Bool, so the caller can distinguish between implicitly and explicitly false.

func PanicIfAnyEnvCheckedInInit added in v1.32.0

func PanicIfAnyEnvCheckedInInit()

PanicIfAnyEnvCheckedInInit panics if environment variables were read during init.

func RegisterBool added in v1.32.0

func RegisterBool(envVar string) func() bool

RegisterBool returns a func that gets the named environment variable, without a map lookup per call. It assumes that mutations happen via envknob.Setenv.

func RegisterDuration added in v1.36.0

func RegisterDuration(envVar string) func() time.Duration

RegisterDuration returns a func that gets the named environment variable as a duration, without a map lookup per call. It assumes that any mutations happen via envknob.Setenv.

func RegisterInt added in v1.38.0

func RegisterInt(envVar string) func() int

RegisterInt returns a func that gets the named environment variable as an integer, without a map lookup per call. It assumes that any mutations happen via envknob.Setenv.

func RegisterOptBool added in v1.32.0

func RegisterOptBool(envVar string) func() opt.Bool

RegisterOptBool returns a func that gets the named environment variable, without a map lookup per call. It assumes that mutations happen via envknob.Setenv.

func RegisterString added in v1.32.0

func RegisterString(envVar string) func() string

RegisterString returns a func that gets the named environment variable, without a map lookup per call. It assumes that mutations happen via envknob.Setenv.

func SSHIgnoreTailnetPolicy added in v1.24.0

func SSHIgnoreTailnetPolicy() bool

SSHIgnoreTailnetPolicy is whether to ignore the Tailnet SSH policy for development.

func SSHPolicyFile added in v1.24.0

func SSHPolicyFile() string

SSHPolicyFile returns the path, if any, to the SSHPolicy JSON file for development.

func SetNoLogsNoSupport added in v1.32.0

func SetNoLogsNoSupport()

SetNoLogsNoSupport enables no-logs-no-support mode.

func Setenv added in v1.32.0

func Setenv(envVar, val string)

Setenv changes an environment variable.

It is not safe for concurrent reading of environment variables via the Register functions. All Setenv calls are meant to happen early in main before any goroutines are started.

func String

func String(envVar string) string

String returns the named environment variable, using os.Getenv.

If the variable is non-empty, it's also tracked & logged as being an in-use knob.

func TKASkipSignatureCheck added in v1.32.0

func TKASkipSignatureCheck() bool

TKASkipSignatureCheck is whether to skip node-key signature checking for development.

func UseWIPCode

func UseWIPCode() bool

UseWIPCode is whether TAILSCALE_USE_WIP_CODE is set to permit use of Work-In-Progress code.

Types

This section is empty.

Directories

Path Synopsis
Package logknob provides a helpful wrapper that allows enabling logging based on either an envknob or other methods of enablement.
Package logknob provides a helpful wrapper that allows enabling logging based on either an envknob or other methods of enablement.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL