-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfig.go
More file actions
95 lines (85 loc) · 2.67 KB
/
Copy pathconfig.go
File metadata and controls
95 lines (85 loc) · 2.67 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package main
import (
"encoding/json"
"io/ioutil"
"log"
"os"
)
// Configuration - configuration structure
type Configuration struct {
ListenParams string `json:"ListenParams"` // [listen address]:[listen port]
Output Output `json:"Output"` // where to store or send collected data
Configv5Header ConfigV5Header `json:"ConfigV5Header"`
ConfigV5Record ConfigV5Record `json:"ConfigV5Record"`
}
// Output -
type Output struct {
ChunkSize int `json:"ChunkSize"` // the size of accumulator
LocalFS LocalFSConf `json:"LocalFS"` // [listen address]:[listen port]
HDFS HDFSConf `json:"HDFS"`
Kafka KafkaConf `json:"Kafka"`
}
// LocalFSConf -
type LocalFSConf struct {
Enabled bool `json:"Enabled"`
Path string `json:"Path"`
}
// HDFSConf -
type HDFSConf struct {
Enabled bool `json:"Enabled"`
Path string `json:"Path"`
}
// KafkaConf -
type KafkaConf struct {
Enabled bool `json:"Enabled"`
BrokerList []string `json:"BrokerList"` // [listen address]:[listen port]
Topic string `json:"Topic"`
TLS KafkaConfTLS `json:"TLS"`
}
// KafkaConfTLS -
type KafkaConfTLS struct {
Enabled bool `json:"Enabled"`
CertFilePath string `json:"CertFilePath"`
KeyFilePath string `json:"KeyFilePath"`
CAFilePath string `json:"CAFilePath"`
}
// ConfigV5Header - struct of enable/disable switches for netflow V5 header fields
type ConfigV5Header struct {
Version bool `json:"Version"`
Count bool `json:"Count"`
SysUptime bool `json:"SysUptime"`
Timestamp bool `json:"Timestamp"`
FlowSequence bool `json:"FlowSequence"`
EngineType bool `json:"EngineType"`
EngineID bool `json:"EngineID"`
SamplingInterval bool `json:"SamplingInterval"`
}
// ConfigV5Record - struct of enable/disable switches for netflow V5 record fields
type ConfigV5Record struct {
SrcAddr bool `json:"SrcAddr"`
DstAddr bool `json:"DstAddr"`
NextHop bool `json:"NextHop"`
Input bool `json:"Input"`
Output bool `json:"Output"`
DPkts bool `json:"DPkts"`
DOctets bool `json:"DOctets"`
First bool `json:"First"`
Last bool `json:"Last"`
SrcPort bool `json:"SrcPort"`
DstPort bool `json:"DstPort"`
TCPFlags bool `json:"TCPFlags"`
Prot bool `json:"Prot"`
Tos bool `json:"Tos"`
SrcAs bool `json:"SrcAs"`
DstAs bool `json:"DstAs"`
SrcMask bool `json:"SrcMask"`
DstMask bool `json:"DstMask"`
}
// ReadConfig - reads configuration JSON file and feeds configuration struct
func ReadConfig(c *Configuration) {
file, e := ioutil.ReadFile(os.Args[1])
if e != nil {
log.Fatalf("cannot read configuration file: %v\n", e)
}
json.Unmarshal(file, c)
}