Update
This commit is contained in:
66
vendor/tailscale.com/tsd/tsd.go
generated
vendored
66
vendor/tailscale.com/tsd/tsd.go
generated
vendored
@@ -25,15 +25,15 @@ import (
|
||||
"tailscale.com/drive"
|
||||
"tailscale.com/health"
|
||||
"tailscale.com/ipn"
|
||||
"tailscale.com/ipn/auditlog"
|
||||
"tailscale.com/ipn/conffile"
|
||||
"tailscale.com/ipn/desktop"
|
||||
"tailscale.com/net/dns"
|
||||
"tailscale.com/net/netmon"
|
||||
"tailscale.com/net/tsdial"
|
||||
"tailscale.com/net/tstun"
|
||||
"tailscale.com/proxymap"
|
||||
"tailscale.com/types/netmap"
|
||||
"tailscale.com/util/eventbus"
|
||||
"tailscale.com/util/syspolicy/policyclient"
|
||||
"tailscale.com/util/usermetric"
|
||||
"tailscale.com/wgengine"
|
||||
"tailscale.com/wgengine/magicsock"
|
||||
@@ -41,7 +41,12 @@ import (
|
||||
)
|
||||
|
||||
// System contains all the subsystems of a Tailscale node (tailscaled, etc.)
|
||||
//
|
||||
// A valid System value must always have a non-nil Bus populated. Callers must
|
||||
// ensure this before using the value further. Call [NewSystem] to obtain a
|
||||
// value ready to use.
|
||||
type System struct {
|
||||
Bus SubSystem[*eventbus.Bus]
|
||||
Dialer SubSystem[*tsdial.Dialer]
|
||||
DNSManager SubSystem[*dns.Manager] // can get its *resolver.Resolver from DNSManager.Resolver
|
||||
Engine SubSystem[wgengine.Engine]
|
||||
@@ -51,11 +56,11 @@ type System struct {
|
||||
Router SubSystem[router.Router]
|
||||
Tun SubSystem[*tstun.Wrapper]
|
||||
StateStore SubSystem[ipn.StateStore]
|
||||
AuditLogStore SubSystem[auditlog.LogStore]
|
||||
Netstack SubSystem[NetstackImpl] // actually a *netstack.Impl
|
||||
DriveForLocal SubSystem[drive.FileSystemForLocal]
|
||||
DriveForRemote SubSystem[drive.FileSystemForRemote]
|
||||
SessionManager SubSystem[desktop.SessionManager]
|
||||
PolicyClient SubSystem[policyclient.Client]
|
||||
HealthTracker SubSystem[*health.Tracker]
|
||||
|
||||
// InitialConfig is initial server config, if any.
|
||||
// It is nil if the node is not in declarative mode.
|
||||
@@ -63,6 +68,10 @@ type System struct {
|
||||
// LocalBackend tracks the current config after any reloads.
|
||||
InitialConfig *conffile.Config
|
||||
|
||||
// SocketPath is the path to the tailscaled Unix socket.
|
||||
// It is used to prevent serve from proxying to our own socket.
|
||||
SocketPath string
|
||||
|
||||
// onlyNetstack is whether the Tun value is a fake TUN device
|
||||
// and we're using netstack for everything.
|
||||
onlyNetstack bool
|
||||
@@ -70,14 +79,37 @@ type System struct {
|
||||
controlKnobs controlknobs.Knobs
|
||||
proxyMap proxymap.Mapper
|
||||
|
||||
healthTracker health.Tracker
|
||||
userMetricsRegistry usermetric.Registry
|
||||
}
|
||||
|
||||
// NewSystem constructs a new otherwise-empty [System] with a
|
||||
// freshly-constructed event bus populated.
|
||||
func NewSystem() *System { return NewSystemWithBus(eventbus.New()) }
|
||||
|
||||
// NewSystemWithBus constructs a new otherwise-empty [System] with an
|
||||
// eventbus provided by the caller. The provided bus must not be nil.
|
||||
// This is mainly intended for testing; for production use call [NewBus].
|
||||
func NewSystemWithBus(bus *eventbus.Bus) *System {
|
||||
if bus == nil {
|
||||
panic("nil eventbus")
|
||||
}
|
||||
sys := new(System)
|
||||
sys.Set(bus)
|
||||
|
||||
tracker := health.NewTracker(bus)
|
||||
sys.Set(tracker)
|
||||
|
||||
return sys
|
||||
}
|
||||
|
||||
// LocalBackend is a fake name for *ipnlocal.LocalBackend to avoid an import cycle.
|
||||
type LocalBackend = any
|
||||
|
||||
// NetstackImpl is the interface that *netstack.Impl implements.
|
||||
// It's an interface for circular dependency reasons: netstack.Impl
|
||||
// references LocalBackend, and LocalBackend has a tsd.System.
|
||||
type NetstackImpl interface {
|
||||
Start(LocalBackend) error
|
||||
UpdateNetstackIPs(*netmap.NetworkMap)
|
||||
}
|
||||
|
||||
@@ -86,6 +118,8 @@ type NetstackImpl interface {
|
||||
// has already been set.
|
||||
func (s *System) Set(v any) {
|
||||
switch v := v.(type) {
|
||||
case *eventbus.Bus:
|
||||
s.Bus.Set(v)
|
||||
case *netmon.Monitor:
|
||||
s.NetMon.Set(v)
|
||||
case *dns.Manager:
|
||||
@@ -108,16 +142,16 @@ func (s *System) Set(v any) {
|
||||
s.MagicSock.Set(v)
|
||||
case ipn.StateStore:
|
||||
s.StateStore.Set(v)
|
||||
case auditlog.LogStore:
|
||||
s.AuditLogStore.Set(v)
|
||||
case NetstackImpl:
|
||||
s.Netstack.Set(v)
|
||||
case drive.FileSystemForLocal:
|
||||
s.DriveForLocal.Set(v)
|
||||
case drive.FileSystemForRemote:
|
||||
s.DriveForRemote.Set(v)
|
||||
case desktop.SessionManager:
|
||||
s.SessionManager.Set(v)
|
||||
case policyclient.Client:
|
||||
s.PolicyClient.Set(v)
|
||||
case *health.Tracker:
|
||||
s.HealthTracker.Set(v)
|
||||
default:
|
||||
panic(fmt.Sprintf("unknown type %T", v))
|
||||
}
|
||||
@@ -147,16 +181,20 @@ func (s *System) ProxyMapper() *proxymap.Mapper {
|
||||
return &s.proxyMap
|
||||
}
|
||||
|
||||
// HealthTracker returns the system health tracker.
|
||||
func (s *System) HealthTracker() *health.Tracker {
|
||||
return &s.healthTracker
|
||||
}
|
||||
|
||||
// UserMetricsRegistry returns the system usermetrics.
|
||||
func (s *System) UserMetricsRegistry() *usermetric.Registry {
|
||||
return &s.userMetricsRegistry
|
||||
}
|
||||
|
||||
// PolicyClientOrDefault returns the policy client if set or a no-op default
|
||||
// otherwise. It always returns a non-nil value.
|
||||
func (s *System) PolicyClientOrDefault() policyclient.Client {
|
||||
if client, ok := s.PolicyClient.GetOK(); ok {
|
||||
return client
|
||||
}
|
||||
return policyclient.Get()
|
||||
}
|
||||
|
||||
// SubSystem represents some subsystem of the Tailscale node daemon.
|
||||
//
|
||||
// A subsystem can be set to a value, and then later retrieved. A subsystem
|
||||
|
||||
Reference in New Issue
Block a user