Skip to content

Commit

Permalink
cmd/tailscaled: don't create a network monitor in the parent tailscal…
Browse files Browse the repository at this point in the history
…ed 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 tailscale#10732

Signed-off-by: Aaron Klotz <aaron@tailscale.com>
  • Loading branch information
dblohm7 committed Jan 3, 2024
1 parent fa36397 commit e32a064
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions cmd/tailscaled/tailscaled.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,29 +324,32 @@ 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)

// 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)
}
sys.InitialConfig = conf
}

netMon, err := netmon.New(func(format string, args ...any) {
logf(format, args...)
})
if err != nil {
return fmt.Errorf("netmon.New: %w", err)
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)
}
sys.Set(netMon)

pol := logpolicy.New(logtail.CollectionNode, netMon, nil /* use log.Printf */)
pol.SetVerbosityLevel(args.verbose)
Expand All @@ -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 {
Expand Down

0 comments on commit e32a064

Please sign in to comment.