-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(Prototype) Remote Command Execution (#177)
- Loading branch information
Showing
17 changed files
with
1,104 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
//go:build darwin && amd64 | ||
// +build darwin,amd64 | ||
|
||
package cmd | ||
|
||
import ( | ||
"embed" | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
) | ||
|
||
//go:embed gossh/gossh-darwin-amd64 | ||
var embeddedGossh embed.FS | ||
|
||
var gosshPath string | ||
|
||
func prepareGosshExecutable() (string, error) { | ||
tempDir, err := os.MkdirTemp("", "temp_exec") | ||
if err != nil { | ||
return "", fmt.Errorf("failed to create temp dir: %w", err) | ||
} | ||
|
||
gosshPath, err = extractGosshExecutable(tempDir, "gossh/gossh-darwin-amd64") | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
return gosshPath, nil | ||
} | ||
|
||
func extractGosshExecutable(tempDir, executableName string) (string, error) { | ||
executableFolder := filepath.Dir(executableName) | ||
err := os.MkdirAll(filepath.Join(tempDir, executableFolder), 0755) | ||
if err != nil { | ||
return "", fmt.Errorf("failed to create folder structure: %w", err) | ||
} | ||
|
||
executablePath := filepath.Join(tempDir, executableName) | ||
|
||
data, err := embeddedGossh.ReadFile(executableName) | ||
if err != nil { | ||
return "", fmt.Errorf("failed to read embedded gossh: %w", err) | ||
} | ||
|
||
err = os.WriteFile(executablePath, data, 0755) | ||
if err != nil { | ||
return "", fmt.Errorf("failed to write gossh to temp path: %w", err) | ||
} | ||
|
||
return executablePath, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
//go:build darwin && arm64 | ||
// +build darwin,arm64 | ||
|
||
package cmd | ||
|
||
import ( | ||
"embed" | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
) | ||
|
||
//go:embed gossh/gossh-darwin-arm64 | ||
var embeddedGossh embed.FS | ||
|
||
var gosshPath string | ||
|
||
func prepareGosshExecutable() (string, error) { | ||
tempDir, err := os.MkdirTemp("", "temp_exec") | ||
if err != nil { | ||
return "", fmt.Errorf("failed to create temp dir: %w", err) | ||
} | ||
|
||
gosshPath, err = extractGosshExecutable(tempDir, "gossh/gossh-darwin-arm64") | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
return gosshPath, nil | ||
} | ||
|
||
func extractGosshExecutable(tempDir, executableName string) (string, error) { | ||
executableFolder := filepath.Dir(executableName) | ||
err := os.MkdirAll(filepath.Join(tempDir, executableFolder), 0755) | ||
if err != nil { | ||
return "", fmt.Errorf("failed to create folder structure: %w", err) | ||
} | ||
|
||
executablePath := filepath.Join(tempDir, executableName) | ||
|
||
data, err := embeddedGossh.ReadFile(executableName) | ||
if err != nil { | ||
return "", fmt.Errorf("failed to read embedded gossh: %w", err) | ||
} | ||
|
||
err = os.WriteFile(executablePath, data, 0755) | ||
if err != nil { | ||
return "", fmt.Errorf("failed to write gossh to temp path: %w", err) | ||
} | ||
|
||
return executablePath, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
//go:build linux && amd64 | ||
// +build linux,amd64 | ||
|
||
package cmd | ||
|
||
import ( | ||
"embed" | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
) | ||
|
||
//go:embed gossh/gossh-linux-amd64 | ||
var embeddedGossh embed.FS | ||
|
||
var gosshPath string | ||
|
||
func prepareGosshExecutable() (string, error) { | ||
tempDir, err := os.MkdirTemp("", "temp_exec") | ||
if err != nil { | ||
return "", fmt.Errorf("failed to create temp dir: %w", err) | ||
} | ||
|
||
gosshPath, err = extractGosshExecutable(tempDir, "gossh/gossh-linux-amd64") | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
return gosshPath, nil | ||
} | ||
|
||
func extractGosshExecutable(tempDir, executableName string) (string, error) { | ||
executableFolder := filepath.Dir(executableName) | ||
err := os.MkdirAll(filepath.Join(tempDir, executableFolder), 0755) | ||
if err != nil { | ||
return "", fmt.Errorf("failed to create folder structure: %w", err) | ||
} | ||
|
||
executablePath := filepath.Join(tempDir, executableName) | ||
|
||
data, err := embeddedGossh.ReadFile(executableName) | ||
if err != nil { | ||
return "", fmt.Errorf("failed to read embedded gossh: %w", err) | ||
} | ||
|
||
err = os.WriteFile(executablePath, data, 0755) | ||
if err != nil { | ||
return "", fmt.Errorf("failed to write gossh to temp path: %w", err) | ||
} | ||
|
||
return executablePath, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
//go:build linux && arm64 | ||
// +build linux,arm64 | ||
|
||
package cmd | ||
|
||
import ( | ||
"embed" | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
) | ||
|
||
//go:embed gossh/gossh-linux-arm64 | ||
var embeddedGossh embed.FS | ||
|
||
var gosshPath string | ||
|
||
func prepareGosshExecutable() (string, error) { | ||
tempDir, err := os.MkdirTemp("", "temp_exec") | ||
if err != nil { | ||
return "", fmt.Errorf("failed to create temp dir: %w", err) | ||
} | ||
|
||
gosshPath, err = extractGosshExecutable(tempDir, "gossh/gossh-linux-arm64") | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
return gosshPath, nil | ||
} | ||
|
||
func extractGosshExecutable(tempDir, executableName string) (string, error) { | ||
executableFolder := filepath.Dir(executableName) | ||
err := os.MkdirAll(filepath.Join(tempDir, executableFolder), 0755) | ||
if err != nil { | ||
return "", fmt.Errorf("failed to create folder structure: %w", err) | ||
} | ||
|
||
executablePath := filepath.Join(tempDir, executableName) | ||
|
||
data, err := embeddedGossh.ReadFile(executableName) | ||
if err != nil { | ||
return "", fmt.Errorf("failed to read embedded gossh: %w", err) | ||
} | ||
|
||
err = os.WriteFile(executablePath, data, 0755) | ||
if err != nil { | ||
return "", fmt.Errorf("failed to write gossh to temp path: %w", err) | ||
} | ||
|
||
return executablePath, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//go:build windows || (linux && arm && !arm64) | ||
// +build windows linux,arm,!arm64 | ||
|
||
package cmd | ||
|
||
import ( | ||
"embed" | ||
) | ||
|
||
var embeddedGossh embed.FS | ||
|
||
var gosshPath string | ||
|
||
func prepareGosshExecutable() (string, error) { | ||
return "", nil | ||
} | ||
|
||
func extractGosshExecutable(_, _ string) (string, error) { | ||
return "", nil | ||
} |
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.