mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 04:55:31 +00:00
control/controlknobs: move more controlknobs code from controlclient
Updates #cleanup Change-Id: I2b8b6ac97589270f307bfb20e33674894ce873b5 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
3af051ea27
commit
9203916a4a
@ -315,7 +315,7 @@ tailscale.com/cmd/tailscaled dependencies: (generated by github.com/tailscale/de
|
|||||||
tailscale.com/types/netlogtype from tailscale.com/net/connstats+
|
tailscale.com/types/netlogtype from tailscale.com/net/connstats+
|
||||||
tailscale.com/types/netmap from tailscale.com/control/controlclient+
|
tailscale.com/types/netmap from tailscale.com/control/controlclient+
|
||||||
tailscale.com/types/nettype from tailscale.com/wgengine/magicsock+
|
tailscale.com/types/nettype from tailscale.com/wgengine/magicsock+
|
||||||
tailscale.com/types/opt from tailscale.com/control/controlclient+
|
tailscale.com/types/opt from tailscale.com/client/tailscale+
|
||||||
tailscale.com/types/persist from tailscale.com/control/controlclient+
|
tailscale.com/types/persist from tailscale.com/control/controlclient+
|
||||||
tailscale.com/types/preftype from tailscale.com/ipn+
|
tailscale.com/types/preftype from tailscale.com/ipn+
|
||||||
tailscale.com/types/ptr from tailscale.com/hostinfo+
|
tailscale.com/types/ptr from tailscale.com/hostinfo+
|
||||||
|
@ -49,7 +49,6 @@
|
|||||||
"tailscale.com/types/key"
|
"tailscale.com/types/key"
|
||||||
"tailscale.com/types/logger"
|
"tailscale.com/types/logger"
|
||||||
"tailscale.com/types/netmap"
|
"tailscale.com/types/netmap"
|
||||||
"tailscale.com/types/opt"
|
|
||||||
"tailscale.com/types/persist"
|
"tailscale.com/types/persist"
|
||||||
"tailscale.com/types/ptr"
|
"tailscale.com/types/ptr"
|
||||||
"tailscale.com/types/tkatype"
|
"tailscale.com/types/tkatype"
|
||||||
@ -1304,49 +1303,6 @@ func initDevKnob() devKnobs {
|
|||||||
|
|
||||||
var clock tstime.Clock = tstime.StdClock{}
|
var clock tstime.Clock = tstime.StdClock{}
|
||||||
|
|
||||||
func (ms *mapSession) setControlKnobsFromNodeAttrs(selfNodeAttrs []string) {
|
|
||||||
k := ms.controlKnobs
|
|
||||||
if k == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
var (
|
|
||||||
keepFullWG bool
|
|
||||||
disableDRPO bool
|
|
||||||
disableUPnP bool
|
|
||||||
randomizeClientPort bool
|
|
||||||
disableDeltaUpdates bool
|
|
||||||
oneCGNAT opt.Bool
|
|
||||||
forceBackgroundSTUN bool
|
|
||||||
)
|
|
||||||
for _, attr := range selfNodeAttrs {
|
|
||||||
switch attr {
|
|
||||||
case tailcfg.NodeAttrDebugDisableWGTrim:
|
|
||||||
keepFullWG = true
|
|
||||||
case tailcfg.NodeAttrDebugDisableDRPO:
|
|
||||||
disableDRPO = true
|
|
||||||
case tailcfg.NodeAttrDisableUPnP:
|
|
||||||
disableUPnP = true
|
|
||||||
case tailcfg.NodeAttrRandomizeClientPort:
|
|
||||||
randomizeClientPort = true
|
|
||||||
case tailcfg.NodeAttrOneCGNATEnable:
|
|
||||||
oneCGNAT.Set(true)
|
|
||||||
case tailcfg.NodeAttrOneCGNATDisable:
|
|
||||||
oneCGNAT.Set(false)
|
|
||||||
case tailcfg.NodeAttrDebugForceBackgroundSTUN:
|
|
||||||
forceBackgroundSTUN = true
|
|
||||||
case tailcfg.NodeAttrDisableDeltaUpdates:
|
|
||||||
disableDeltaUpdates = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
k.KeepFullWGConfig.Store(keepFullWG)
|
|
||||||
k.DisableDRPO.Store(disableDRPO)
|
|
||||||
k.DisableUPnP.Store(disableUPnP)
|
|
||||||
k.RandomizeClientPort.Store(randomizeClientPort)
|
|
||||||
k.OneCGNAT.Store(oneCGNAT)
|
|
||||||
k.ForceBackgroundSTUN.Store(forceBackgroundSTUN)
|
|
||||||
k.DisableDeltaUpdates.Store(disableDeltaUpdates)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ipForwardingBroken reports whether the system's IP forwarding is disabled
|
// ipForwardingBroken reports whether the system's IP forwarding is disabled
|
||||||
// and will definitely not work for the routes provided.
|
// and will definitely not work for the routes provided.
|
||||||
//
|
//
|
||||||
|
@ -188,7 +188,7 @@ func (ms *mapSession) HandleNonKeepAliveMapResponse(ctx context.Context, resp *t
|
|||||||
if DevKnob.StripCaps() {
|
if DevKnob.StripCaps() {
|
||||||
resp.Node.Capabilities = nil
|
resp.Node.Capabilities = nil
|
||||||
}
|
}
|
||||||
ms.setControlKnobsFromNodeAttrs(resp.Node.Capabilities)
|
ms.controlKnobs.UpdateFromNodeAttributes(resp.Node.Capabilities)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call Node.InitDisplayNames on any changed nodes.
|
// Call Node.InitDisplayNames on any changed nodes.
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
"tailscale.com/syncs"
|
"tailscale.com/syncs"
|
||||||
|
"tailscale.com/tailcfg"
|
||||||
"tailscale.com/types/opt"
|
"tailscale.com/types/opt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,6 +46,50 @@ type Knobs struct {
|
|||||||
DisableDeltaUpdates atomic.Bool
|
DisableDeltaUpdates atomic.Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UpdateFromNodeAttributes updates k (if non-nil) based on the provided self
|
||||||
|
// node attributes (Node.Capabilities).
|
||||||
|
func (k *Knobs) UpdateFromNodeAttributes(selfNodeAttrs []string) {
|
||||||
|
if k == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var (
|
||||||
|
keepFullWG bool
|
||||||
|
disableDRPO bool
|
||||||
|
disableUPnP bool
|
||||||
|
randomizeClientPort bool
|
||||||
|
disableDeltaUpdates bool
|
||||||
|
oneCGNAT opt.Bool
|
||||||
|
forceBackgroundSTUN bool
|
||||||
|
)
|
||||||
|
for _, attr := range selfNodeAttrs {
|
||||||
|
switch attr {
|
||||||
|
case tailcfg.NodeAttrDebugDisableWGTrim:
|
||||||
|
keepFullWG = true
|
||||||
|
case tailcfg.NodeAttrDebugDisableDRPO:
|
||||||
|
disableDRPO = true
|
||||||
|
case tailcfg.NodeAttrDisableUPnP:
|
||||||
|
disableUPnP = true
|
||||||
|
case tailcfg.NodeAttrRandomizeClientPort:
|
||||||
|
randomizeClientPort = true
|
||||||
|
case tailcfg.NodeAttrOneCGNATEnable:
|
||||||
|
oneCGNAT.Set(true)
|
||||||
|
case tailcfg.NodeAttrOneCGNATDisable:
|
||||||
|
oneCGNAT.Set(false)
|
||||||
|
case tailcfg.NodeAttrDebugForceBackgroundSTUN:
|
||||||
|
forceBackgroundSTUN = true
|
||||||
|
case tailcfg.NodeAttrDisableDeltaUpdates:
|
||||||
|
disableDeltaUpdates = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
k.KeepFullWGConfig.Store(keepFullWG)
|
||||||
|
k.DisableDRPO.Store(disableDRPO)
|
||||||
|
k.DisableUPnP.Store(disableUPnP)
|
||||||
|
k.RandomizeClientPort.Store(randomizeClientPort)
|
||||||
|
k.OneCGNAT.Store(oneCGNAT)
|
||||||
|
k.ForceBackgroundSTUN.Store(forceBackgroundSTUN)
|
||||||
|
k.DisableDeltaUpdates.Store(disableDeltaUpdates)
|
||||||
|
}
|
||||||
|
|
||||||
// AsDebugJSON returns k as something that can be marshalled with json.Marshal
|
// AsDebugJSON returns k as something that can be marshalled with json.Marshal
|
||||||
// for debug.
|
// for debug.
|
||||||
func (k *Knobs) AsDebugJSON() map[string]any {
|
func (k *Knobs) AsDebugJSON() map[string]any {
|
||||||
|
Loading…
Reference in New Issue
Block a user