2023-01-27 21:37:20 +00:00
|
|
|
// Copyright (c) Tailscale Inc & AUTHORS
|
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
2021-06-22 22:29:01 +00:00
|
|
|
|
|
|
|
// Package controlknobs contains client options configurable from control which can be turned on
|
|
|
|
// or off. The ability to turn options on and off is for incrementally adding features in.
|
|
|
|
package controlknobs
|
|
|
|
|
|
|
|
import (
|
2022-08-04 04:51:02 +00:00
|
|
|
"sync/atomic"
|
|
|
|
|
2022-01-24 18:52:57 +00:00
|
|
|
"tailscale.com/envknob"
|
2021-06-22 22:29:01 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// disableUPnP indicates whether to attempt UPnP mapping.
|
2022-09-14 19:49:39 +00:00
|
|
|
var disableUPnPControl atomic.Bool
|
2021-06-22 22:29:01 +00:00
|
|
|
|
2022-09-14 19:49:39 +00:00
|
|
|
var disableUPnpEnv = envknob.RegisterBool("TS_DISABLE_UPNP")
|
2021-06-22 22:29:01 +00:00
|
|
|
|
|
|
|
// DisableUPnP reports the last reported value from control
|
|
|
|
// whether UPnP portmapping should be disabled.
|
2021-07-16 05:34:50 +00:00
|
|
|
func DisableUPnP() bool {
|
2022-09-14 19:49:39 +00:00
|
|
|
return disableUPnPControl.Load() || disableUPnpEnv()
|
2021-06-22 22:29:01 +00:00
|
|
|
}
|
|
|
|
|
2021-07-16 05:34:50 +00:00
|
|
|
// SetDisableUPnP sets whether control says that UPnP should be
|
|
|
|
// disabled.
|
|
|
|
func SetDisableUPnP(v bool) {
|
2022-09-14 19:49:39 +00:00
|
|
|
disableUPnPControl.Store(v)
|
2021-06-22 22:29:01 +00:00
|
|
|
}
|