controlknobs.go 831 B

1234567891011121314151617181920212223242526272829
  1. // Copyright (c) Tailscale Inc & AUTHORS
  2. // SPDX-License-Identifier: BSD-3-Clause
  3. // Package controlknobs contains client options configurable from control which can be turned on
  4. // or off. The ability to turn options on and off is for incrementally adding features in.
  5. package controlknobs
  6. import (
  7. "sync/atomic"
  8. "tailscale.com/envknob"
  9. )
  10. // disableUPnP indicates whether to attempt UPnP mapping.
  11. var disableUPnPControl atomic.Bool
  12. var disableUPnpEnv = envknob.RegisterBool("TS_DISABLE_UPNP")
  13. // DisableUPnP reports the last reported value from control
  14. // whether UPnP portmapping should be disabled.
  15. func DisableUPnP() bool {
  16. return disableUPnPControl.Load() || disableUPnpEnv()
  17. }
  18. // SetDisableUPnP sets whether control says that UPnP should be
  19. // disabled.
  20. func SetDisableUPnP(v bool) {
  21. disableUPnPControl.Store(v)
  22. }