-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
38 lines (34 loc) · 923 Bytes
/
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
package main
import (
"encoding/json"
"os"
)
type Configuration struct {
Logfiles []string `json:"logfiles"`
DatabasePath string `json:"databasePath"`
MyPage string `json:"myPage"`
RegEx string `json:"regExp"`
Mode string `json:"mode"`
RegGroupDate int `json:"regGroupDate"`
RegGroupIP int `json:"regGroupIP"`
RegGroupPage int `json:"regGroupPage"`
MinAttacks int `json:"minAttacks"`
SmtpHost string `json:"smtpHost"`
SmtpUser string `json:"smtpUser"`
SmtpPwd string `json:"smtpPwd"`
SmtpCopy string `json:"smtpCopy"`
}
var cfg Configuration
func loadConfig() {
file, err := os.Open(*configFile)
if err != nil {
panic("Config file not found or not given!")
}
defer file.Close()
decoder := json.NewDecoder(file)
cfg = Configuration{}
err = decoder.Decode(&cfg)
if err != nil {
panic("Invalid config.json")
}
}