From 689426d6bc97a1da3fd1d977127ac63598562bfb Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Wed, 15 Dec 2021 20:44:51 -0800 Subject: [PATCH] cmd/tailscaled: log Windows service change requests And add a little comment. Change-Id: If0bedf8aefd8d528149548fba829e7a9a8b2e114 Signed-off-by: Brad Fitzpatrick --- cmd/tailscaled/tailscaled_windows.go | 42 ++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/cmd/tailscaled/tailscaled_windows.go b/cmd/tailscaled/tailscaled_windows.go index 74a02b7b6..3f41f9560 100644 --- a/cmd/tailscaled/tailscaled_windows.go +++ b/cmd/tailscaled/tailscaled_windows.go @@ -55,6 +55,11 @@ func isWindowsService() bool { return v } +// runWindowsService starts running Tailscale under the Windows +// Service environment. +// +// At this point we're still the parent process that +// Windows started. func runWindowsService(pol *logpolicy.Policy) error { return svc.Run(serviceName, &ipnService{Policy: pol}) } @@ -93,6 +98,7 @@ func (service *ipnService) Execute(args []string, r <-chan svc.ChangeRequest, ch select { case <-doneCh: case cmd := <-r: + log.Printf("Got Windows Service event: %v", cmdName(cmd.Cmd)) switch cmd.Cmd { case svc.Stop: cancel() @@ -109,6 +115,42 @@ func (service *ipnService) Execute(args []string, r <-chan svc.ChangeRequest, ch return false, windows.NO_ERROR } +func cmdName(c svc.Cmd) string { + switch c { + case svc.Stop: + return "Stop" + case svc.Pause: + return "Pause" + case svc.Continue: + return "Continue" + case svc.Interrogate: + return "Interrogate" + case svc.Shutdown: + return "Shutdown" + case svc.ParamChange: + return "ParamChange" + case svc.NetBindAdd: + return "NetBindAdd" + case svc.NetBindRemove: + return "NetBindRemove" + case svc.NetBindEnable: + return "NetBindEnable" + case svc.NetBindDisable: + return "NetBindDisable" + case svc.DeviceEvent: + return "DeviceEvent" + case svc.HardwareProfileChange: + return "HardwareProfileChange" + case svc.PowerEvent: + return "PowerEvent" + case svc.SessionChange: + return "SessionChange" + case svc.PreShutdown: + return "PreShutdown" + } + return fmt.Sprintf("Unknown-Service-Cmd-%d", c) +} + func beWindowsSubprocess() bool { if beFirewallKillswitch() { return true