controlknobs.go 892 B

12345678910111213141516171819202122232425262728293031
  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. "tailscale.com/envknob"
  9. "tailscale.com/syncs"
  10. )
  11. // disableUPnP indicates whether to attempt UPnP mapping.
  12. var disableUPnP syncs.AtomicBool
  13. func init() {
  14. SetDisableUPnP(envknob.Bool("TS_DISABLE_UPNP"))
  15. }
  16. // DisableUPnP reports the last reported value from control
  17. // whether UPnP portmapping should be disabled.
  18. func DisableUPnP() bool {
  19. return disableUPnP.Get()
  20. }
  21. // SetDisableUPnP sets whether control says that UPnP should be
  22. // disabled.
  23. func SetDisableUPnP(v bool) {
  24. disableUPnP.Set(v)
  25. }