-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathconfig.go
58 lines (41 loc) · 1.35 KB
/
config.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
51
52
53
54
55
56
57
58
/*
* the config for main
* Author:asmcos
* Date:2021.2
*/
package main
import (
"encoding/json"
"io/ioutil"
"log"
)
/*****************************
config value
******************************/
var colorReset = "\033[0m"
var colorRed = "\033[31m"
func loadConfig(){
f, err := ioutil.ReadFile("sniffer.json")
if err != nil {
log.Println("**********************************************")
log.Println(colorRed,"Warning: Read config sniffer.json fail,use default config value.", err,colorReset)
log.Println("**********************************************")
return
}
var configData map[string]interface{}
err = json.Unmarshal([]byte(f), &configData)
if err != nil {
log.Println("sniffer.json err,user default config",err)
return
}
log.Println("Load config file :sniffer.json success!\n")
*iface = configData["device"].(string)
*port = int(configData["port"].(float64))
*djslen = int(configData["jslength"].(float64))
*dhtmllen = int(configData["htmllength"].(float64))
*danystr = configData["dumpanystr"].(string)
*danylen = int(configData["dumpanylen"].(float64))
*serverurl = configData["serverurl"].(string)
clientDeviceid = configData["clientDeviceid"].(string)
clientDevicekey = configData["clientDevicekey"].(string)
}