mirror of
				https://github.com/tailscale/tailscale.git
				synced 2025-10-31 03:49:52 +00:00 
			
		
		
		
	
		
			
	
	
		
			36 lines
		
	
	
		
			771 B
		
	
	
	
		
			Go
		
	
	
	
	
	
		
		
			
		
	
	
			36 lines
		
	
	
		
			771 B
		
	
	
	
		
			Go
		
	
	
	
	
	
|   | // Copyright (c) 2021 Tailscale Inc & AUTHORS All rights reserved. | ||
|  | // Use of this source code is governed by a BSD-style | ||
|  | // license that can be found in the LICENSE file. | ||
|  | 
 | ||
|  | //go:build linux || windows || darwin || freebsd | ||
|  | 
 | ||
|  | package safesocket | ||
|  | 
 | ||
|  | import ( | ||
|  | 	"strings" | ||
|  | 
 | ||
|  | 	ps "github.com/mitchellh/go-ps" | ||
|  | ) | ||
|  | 
 | ||
|  | func init() { | ||
|  | 	tailscaledProcExists = 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 | ||
|  | 	} | ||
|  | } |