cmd/tailscaled: don't create a network monitor in the parent tailscaled on Windows

The service is only used as a watchdog and for piping logs from the child
process. We shouldn't be creating a network monitor in that case.

Fixes #10732

Signed-off-by: Aaron Klotz <aaron@tailscale.com>
pull/10734/head
Aaron Klotz 11 months ago
parent fa3639783c
commit e32a064659

@ -324,7 +324,7 @@ func ipnServerOpts() (o serverOptions) {
var logPol *logpolicy.Policy
var debugMux *http.ServeMux
func run() error {
func run() (err error) {
var logf logger.Logf = log.Printf
sys := new(tsd.System)
@ -332,7 +332,6 @@ func run() error {
// Parse config, if specified, to fail early if it's invalid.
var conf *conffile.Config
if args.confFile != "" {
var err error
conf, err = conffile.Load(args.confFile)
if err != nil {
return fmt.Errorf("error reading config file: %w", err)
@ -340,13 +339,17 @@ func run() error {
sys.InitialConfig = conf
}
netMon, err := netmon.New(func(format string, args ...any) {
var netMon *netmon.Monitor
isWinSvc := isWindowsService()
if !isWinSvc {
netMon, err = netmon.New(func(format string, args ...any) {
logf(format, args...)
})
if err != nil {
return fmt.Errorf("netmon.New: %w", err)
}
sys.Set(netMon)
}
pol := logpolicy.New(logtail.CollectionNode, netMon, nil /* use log.Printf */)
pol.SetVerbosityLevel(args.verbose)
@ -362,7 +365,7 @@ func run() error {
log.Printf("Error reading environment config: %v", err)
}
if isWindowsService() {
if isWinSvc {
// Run the IPN server from the Windows service manager.
log.Printf("Running service...")
if err := runWindowsService(pol); err != nil {

Loading…
Cancel
Save