controlknobs.go 920 B

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