-
Notifications
You must be signed in to change notification settings - Fork 6
/
finger.go
50 lines (45 loc) · 963 Bytes
/
finger.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package finger
import (
"github.com/Athena1337/blackJack/utils"
"encoding/json"
"github.com/t43Wiu6/tlog"
"io/ioutil"
"os"
"path/filepath"
)
type Config struct {
Rules []Finger
}
type MetaFinger struct {
Method string
Location string
StatusCode int
Keyword []string
}
type Finger struct {
Name string
Fingerprint []MetaFinger
}
func LoadFinger() (configs Config, err error) {
filePath, err := utils.GetCurrentAbPathByCaller()
if err == nil{
home, _ := os.UserHomeDir()
filePath = filepath.Join(home, ".blackJack", "finger.json")
dat, errs := ioutil.ReadFile(filePath)
if errs != nil {
log.Warnf("finger.json not found, unable to read config file: %s", filePath)
return configs, errs
}
err = json.Unmarshal(dat, &configs)
if err != nil {
log.Errorf("%s", err)
return
}
}
a := 0
for _, k := range configs.Rules {
a = a + len(k.Fingerprint)
}
log.Infof("Totally load finger %d 's", a)
return
}