-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
43 lines (39 loc) · 986 Bytes
/
main.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
package main
import (
"GoFender/Database"
"GoFender/GetPacket"
"GoFender/MessageQueue"
"GoFender/SuricataMatch"
"GoFender/WebServer"
"GoFender/YamlConfig"
"github.com/google/gopacket"
_ "net/http/pprof"
)
func main() {
go WebServer.WebStart()
PacketChan := make(chan gopacket.Packet, 10240)
defer close(PacketChan)
go func() {
err := GetPacket.CapturePackets(PacketChan)
if err != nil {
panic(err)
}
}()
if PacketChan != nil {
handel := MessageQueue.ConsumerGroupHandler{}
go func() {
for {
Packet := <-PacketChan
MessageQueue.ProducerPacket(Packet, "Packet_Data")
}
}()
handel.ConsumerPacket("Packet_Data")
}
}
func init() {
YamlConfig.Myconfig = YamlConfig.ParseYaml("./config.yaml")
MessageQueue.Producer = MessageQueue.InitKafka()
Database.DataPool = Database.InitDatabase()
SuricataMatch.RuleSet = SuricataMatch.RulesParse(YamlConfig.Myconfig.RulesPath)
SuricataMatch.ACTrie = SuricataMatch.BulidTrie(SuricataMatch.RuleSet)
}