use os.Executable to discover the path to cloudflared (#1040)

This commit is contained in:
Alex Vanderpot 2023-12-14 17:32:31 +01:00 committed by GitHub
parent fd5d8260bb
commit f51be82729
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -478,6 +478,11 @@ func processURL(s string) (*url.URL, error) {
// cloudflaredPath pulls the full path of cloudflared on disk // cloudflaredPath pulls the full path of cloudflared on disk
func cloudflaredPath() string { func cloudflaredPath() string {
path, err := os.Executable()
if err == nil && isFileThere(path) {
return path
}
for _, p := range strings.Split(os.Getenv("PATH"), ":") { for _, p := range strings.Split(os.Getenv("PATH"), ":") {
path := fmt.Sprintf("%s/%s", p, "cloudflared") path := fmt.Sprintf("%s/%s", p, "cloudflared")
if isFileThere(path) { if isFileThere(path) {