MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / IsAvailable

Function IsAvailable

internal/browser/browser.go:86–112  ·  view source on GitHub ↗

IsAvailable checks if the system has a command available to open a web browser. It verifies the presence of necessary commands for the current operating system. Returns: - true if a browser can be opened, false otherwise.

()

Source from the content-addressed store, hash-verified

84// Returns:
85// - true if a browser can be opened, false otherwise.
86func IsAvailable() bool {
87 // First check if open-golang can work
88 testErr := open.Run("about:blank")
89 if testErr == nil {
90 return true
91 }
92
93 // Check platform-specific commands
94 switch runtime.GOOS {
95 case "darwin":
96 _, err := exec.LookPath("open")
97 return err == nil
98 case "windows":
99 _, err := exec.LookPath("rundll32")
100 return err == nil
101 case "linux":
102 browsers := []string{"xdg-open", "x-www-browser", "www-browser", "firefox", "chromium", "google-chrome"}
103 for _, browser := range browsers {
104 if _, err := exec.LookPath(browser); err == nil {
105 return true
106 }
107 }
108 return false
109 default:
110 return false
111 }
112}
113
114// GetPlatformInfo returns a map containing details about the current platform's
115// browser opening capabilities, including the OS, architecture, and available commands.

Callers 7

LoginMethod · 0.92
LoginMethod · 0.92
LoginMethod · 0.92
LoginMethod · 0.92
loginWithDeviceFlowMethod · 0.92
LoginMethod · 0.92
GetPlatformInfoFunction · 0.85

Calls 1

RunMethod · 0.80

Tested by

no test coverage detected