mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 21:13:18 -07:00
Added caplets windows compatibility
This commit is contained in:
parent
11d2756283
commit
c46bb905b9
3 changed files with 25 additions and 5 deletions
|
@ -2,7 +2,9 @@ package caplets
|
|||
|
||||
import (
|
||||
"os"
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
|
||||
"github.com/evilsocket/islazy/str"
|
||||
)
|
||||
|
@ -11,22 +13,36 @@ const (
|
|||
EnvVarName = "CAPSPATH"
|
||||
Suffix = ".cap"
|
||||
InstallArchive = "https://github.com/bettercap/caplets/archive/master.zip"
|
||||
InstallBase = "/usr/local/share/bettercap/"
|
||||
)
|
||||
|
||||
func getInstallBase() string {
|
||||
if runtime.GOOS == "windows" {
|
||||
return filepath.Join(os.Getenv("ALLUSERSPROFILE"), "bettercap")
|
||||
}
|
||||
return "/usr/local/share/bettercap/"
|
||||
}
|
||||
|
||||
func getUserHomeDir() string {
|
||||
usr, _ := user.Current()
|
||||
return usr.HomeDir
|
||||
}
|
||||
|
||||
var (
|
||||
InstallBase = getInstallBase()
|
||||
InstallPathArchive = filepath.Join(InstallBase, "caplets-master")
|
||||
InstallPath = filepath.Join(InstallBase, "caplets")
|
||||
ArchivePath = filepath.Join(os.TempDir(), "caplets.zip")
|
||||
|
||||
LoadPaths = []string{
|
||||
"./",
|
||||
"./caplets/",
|
||||
InstallPath,
|
||||
filepath.Join(getUserHomeDir(), "caplets"),
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
for _, path := range str.SplitBy(str.Trim(os.Getenv(EnvVarName)), ":") {
|
||||
for _, path := range str.SplitBy(str.Trim(os.Getenv(EnvVarName)), string(os.PathListSeparator)) {
|
||||
if path = str.Trim(path); len(path) > 0 {
|
||||
LoadPaths = append(LoadPaths, path)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue