MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / openBrowser

Function openBrowser

internal/vnc/service.go:119–142  ·  view source on GitHub ↗

openBrowser opens the specified URL in the user's default browser.

(url string)

Source from the content-addressed store, hash-verified

117
118// openBrowser opens the specified URL in the user's default browser.
119func openBrowser(url string) error {
120 var cmd string
121 var args []string
122
123 switch runtime.GOOS {
124 case "windows":
125 // Use rundll32 with shell32.dll,ShellExec_RunDLL to avoid cmd length limitations
126 // This method is more reliable for long URLs with query parameters
127 cmd = "rundll32"
128 args = []string{"url.dll,FileProtocolHandler", url}
129 case "darwin":
130 cmd = "open"
131 args = []string{url}
132 default: // "linux", "freebsd", "openbsd", "netbsd"
133 // Check if xdg-open is available before trying to use it
134 if _, err := exec.LookPath("xdg-open"); err != nil {
135 return fmt.Errorf("xdg-open not found: %w", err)
136 }
137 cmd = "xdg-open"
138 args = []string{url}
139 }
140
141 return exec.Command(cmd, args...).Start()
142}
143
144// createShortenedVNCURL creates a shortened URL that forwards to the actual VNC URL
145func createShortenedVNCURL(actualURL string) string {

Callers 5

ConnectToVMMethod · 0.85
ConnectToNodeMethod · 0.85

Calls

no outgoing calls

Tested by 1