misc: refactored caplets code in a dedicated package

This commit is contained in:
evilsocket 2018-09-21 15:15:27 +02:00
commit 9721c1d6e0
7 changed files with 209 additions and 157 deletions

32
caplets/env.go Normal file
View file

@ -0,0 +1,32 @@
package caplets
import (
"os"
"path/filepath"
"github.com/bettercap/bettercap/core"
)
const (
Suffix = ".cap"
InstallPath = "/usr/local/share/bettercap/caplets/"
)
var (
LoadPaths = []string{
"./caplets/",
InstallPath,
}
)
func init() {
for _, path := range core.SepSplit(core.Trim(os.Getenv("CAPSPATH")), ":") {
if path = core.Trim(path); len(path) > 0 {
LoadPaths = append(LoadPaths, path)
}
}
for i, path := range LoadPaths {
LoadPaths[i], _ = filepath.Abs(path)
}
}