mirror of
				https://github.com/tailscale/tailscale.git
				synced 2025-10-31 08:11:32 +01:00 
			
		
		
		
	Updates #12614 Change-Id: I09b8944166ee00910b402bcd5725cd7969e2c82c Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
		
			
				
	
	
		
			35 lines
		
	
	
		
			735 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
		
			735 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Copyright (c) Tailscale Inc & AUTHORS
 | |
| // SPDX-License-Identifier: BSD-3-Clause
 | |
| 
 | |
| //go:build ((linux && !android) || windows || (darwin && !ios) || freebsd) && !ts_omit_cliconndiag
 | |
| 
 | |
| package safesocket
 | |
| 
 | |
| import (
 | |
| 	"strings"
 | |
| 
 | |
| 	ps "github.com/mitchellh/go-ps"
 | |
| )
 | |
| 
 | |
| func init() {
 | |
| 	tailscaledProcExists.Set(func() bool {
 | |
| 		procs, err := ps.Processes()
 | |
| 		if err != nil {
 | |
| 			return false
 | |
| 		}
 | |
| 		for _, proc := range procs {
 | |
| 			name := proc.Executable()
 | |
| 			const tailscaled = "tailscaled"
 | |
| 			if len(name) < len(tailscaled) {
 | |
| 				continue
 | |
| 			}
 | |
| 			// Do case insensitive comparison for Windows,
 | |
| 			// notably, and ignore any ".exe" suffix.
 | |
| 			if strings.EqualFold(name[:len(tailscaled)], tailscaled) {
 | |
| 				return true
 | |
| 			}
 | |
| 		}
 | |
| 		return false
 | |
| 	})
 | |
| }
 |