forked from zr-hebo/sniffer-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
55 lines (45 loc) · 1000 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
44
45
46
47
48
49
50
51
52
53
54
55
package main
import (
"flag"
"os"
log "github.com/golang/glog"
"github.com/zr-hebo/sniffer-agent/capture"
"github.com/zr-hebo/sniffer-agent/communicator"
"github.com/zr-hebo/sniffer-agent/exporter"
sd "github.com/zr-hebo/sniffer-agent/session-dealer"
"github.com/zr-hebo/sniffer-agent/session-dealer/mysql"
)
var (
logLevel string
)
func init() {
flag.StringVar(&logLevel, "log_level", "warn", "log level. Default is info")
}
func initLog() {
}
func main() {
flag.Parse()
prepareEnv()
go communicator.Server()
mainServer()
}
func mainServer() {
ept := exporter.NewExporter()
networkCard := capture.NewNetworkCard()
log.Info("begin listen")
for queryPiece := range networkCard.Listen() {
err := ept.Export(queryPiece)
if err != nil {
log.Error(err.Error())
}
queryPiece.Recovery()
}
log.Errorf("cannot get network package from %s", capture.DeviceName)
os.Exit(1)
}
func prepareEnv() {
initLog()
sd.CheckParams()
mysql.PrepareEnv()
capture.ShowLocalIP()
}