mirror of
https://github.com/tailscale/tailscale.git
synced 2025-04-16 11:41:39 +00:00
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>
This commit is contained in:
parent
cc9cf97cbe
commit
df7899759d
@ -44,8 +44,6 @@ import (
|
|||||||
|
|
||||||
const serviceName = "Tailscale"
|
const serviceName = "Tailscale"
|
||||||
|
|
||||||
var flushDNSOnSessionUnlock bool
|
|
||||||
|
|
||||||
func isWindowsService() bool {
|
func isWindowsService() bool {
|
||||||
v, err := svc.IsWindowsService()
|
v, err := svc.IsWindowsService()
|
||||||
if err != nil {
|
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) {
|
func (service *ipnService) Execute(args []string, r <-chan svc.ChangeRequest, changes chan<- svc.Status) (bool, uint32) {
|
||||||
changes <- svc.Status{State: svc.StartPending}
|
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())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
doneCh := make(chan struct{})
|
doneCh := make(chan struct{})
|
||||||
go func() {
|
go func() {
|
||||||
@ -75,7 +77,7 @@ func (service *ipnService) Execute(args []string, r <-chan svc.ChangeRequest, ch
|
|||||||
ipnserver.BabysitProc(ctx, args, log.Printf)
|
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 {
|
for ctx.Err() == nil {
|
||||||
select {
|
select {
|
||||||
@ -272,8 +274,7 @@ func startIPNServer(ctx context.Context, logid string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func handleSessionChange(chgRequest svc.ChangeRequest) {
|
func handleSessionChange(chgRequest svc.ChangeRequest) {
|
||||||
if chgRequest.Cmd != svc.SessionChange || chgRequest.EventType != windows.WTS_SESSION_UNLOCK ||
|
if chgRequest.Cmd != svc.SessionChange || chgRequest.EventType != windows.WTS_SESSION_UNLOCK {
|
||||||
!flushDNSOnSessionUnlock {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user