2021-06-22 22:29:01 +00:00
|
|
|
// Copyright (c) 2021 Tailscale Inc & AUTHORS All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
// 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-08-04 04:51:02 +00:00
|
|
|
var disableUPnP atomic.Bool
|
2021-06-22 22:29:01 +00:00
|
|
|
|
|
|
|
func init() {
|
2022-01-24 18:52:57 +00:00
|
|
|
SetDisableUPnP(envknob.Bool("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-08-04 04:51:02 +00:00
|
|
|
return disableUPnP.Load()
|
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-08-04 04:51:02 +00:00
|
|
|
disableUPnP.Store(v)
|
2021-06-22 22:29:01 +00:00
|
|
|
}
|