summaryrefslogtreecommitdiffhomepage
path: root/cmd
diff options
context:
space:
mode:
authorAaron Klotz <aaron@tailscale.com>2021-10-06 09:41:34 -0600
committerAaron Klotz <aaron@tailscale.com>2021-10-06 10:23:55 -0600
commitdf7899759d3a23cbde4a66cdbd158facbecccf7f (patch)
treea268dc944277de2d110acfc2696fcce38d51eb08 /cmd
parentcc9cf97cbed5eb24be623f0233a6f3d3a47b9473 (diff)
downloadtailscale-df7899759d3a23cbde4a66cdbd158facbecccf7f.tar.xz
tailscale-df7899759d3a23cbde4a66cdbd158facbecccf7f.zip
cmd/tailscaled: set the correct flag for receiving Windows session change events
This feature wasn't working until I realized that we also need to opt into the events. MSDN wasn't so generous as to make this easy to deduce. Updates #2956 Signed-off-by: Aaron Klotz <aaron@tailscale.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/tailscaled/tailscaled_windows.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/cmd/tailscaled/tailscaled_windows.go b/cmd/tailscaled/tailscaled_windows.go
index 5b94eb6c7..303581636 100644
--- a/cmd/tailscaled/tailscaled_windows.go
+++ b/cmd/tailscaled/tailscaled_windows.go
@@ -44,8 +44,6 @@ import (
const serviceName = "Tailscale"
-var flushDNSOnSessionUnlock bool
-
func isWindowsService() bool {
v, err := svc.IsWindowsService()
if err != nil {
@@ -66,7 +64,11 @@ type ipnService struct {
func (service *ipnService) Execute(args []string, r <-chan svc.ChangeRequest, changes chan<- svc.Status) (bool, uint32) {
changes <- svc.Status{State: svc.StartPending}
- flushDNSOnSessionUnlock = winutil.GetRegInteger("FlushDNSOnSessionUnlock", 0) != 0
+ svcAccepts := svc.AcceptStop
+ if winutil.GetRegInteger("FlushDNSOnSessionUnlock", 0) != 0 {
+ svcAccepts |= svc.AcceptSessionChange
+ }
+
ctx, cancel := context.WithCancel(context.Background())
doneCh := make(chan struct{})
go func() {
@@ -75,7 +77,7 @@ func (service *ipnService) Execute(args []string, r <-chan svc.ChangeRequest, ch
ipnserver.BabysitProc(ctx, args, log.Printf)
}()
- changes <- svc.Status{State: svc.Running, Accepts: svc.AcceptStop}
+ changes <- svc.Status{State: svc.Running, Accepts: svcAccepts}
for ctx.Err() == nil {
select {
@@ -272,8 +274,7 @@ func startIPNServer(ctx context.Context, logid string) error {
}
func handleSessionChange(chgRequest svc.ChangeRequest) {
- if chgRequest.Cmd != svc.SessionChange || chgRequest.EventType != windows.WTS_SESSION_UNLOCK ||
- !flushDNSOnSessionUnlock {
+ if chgRequest.Cmd != svc.SessionChange || chgRequest.EventType != windows.WTS_SESSION_UNLOCK {
return
}