-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
71 lines (55 loc) · 1.85 KB
/
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package main
import (
"github.com/jagandecapri/vision/preprocess"
"github.com/jagandecapri/vision/process"
"log"
"sort"
"gopkg.in/natefinch/lumberjack.v2"
"github.com/jagandecapri/vision/anomalies"
"github.com/jagandecapri/vision/utils"
"github.com/jagandecapri/vision/data"
"github.com/jagandecapri/vision/cmd"
"github.com/pkg/profile"
)
func getSorter() []string{
sorter := []string{}
sorter = append(sorter, "nbPacket", "nbSrcPort", "nbDstPort",
"nbSrcs", "nbDsts", "perSYN", "perACK", "perRST", "perFIN",
"perCWR", "perURG", "perICMP", "avgPktSize", "meanTTL")
sort.Strings(sorter)
return sorter
}
func main(){
cmd.Execute()
if cmd.PrepareData{
data.Run(cmd.PcapFilePath, cmd.DbNamePrepareData, cmd.DeltaTPrepareData)
}
if cmd.ClusterData{
if cmd.CpuProfile{
defer profile.Start(profile.CPUProfile).Stop()
}
if cmd.MemProfile{
defer profile.Start(profile.MemProfileRate(2048)).Stop()
}
log.SetOutput(&lumberjack.Logger{
Filename: cmd.LogPath,
MaxSize: 5000, // megabytes
})
done := make(chan struct{})
sorter:= getSorter()
config := utils.Config{Min_dense_points: cmd.MinDensePoints, Min_cluster_points: cmd.MinClusterPoints, Points_mode: cmd.PointsMode, Num_cpu: cmd.NumCpu}
subspace_channel_containers := anomalies.ClusteringBuilder(config, done)
acc_c_receive := preprocess.AccumulatorChannels{
AggSrc: make(preprocess.AccumulatorChannel),
AggDst: make(preprocess.AccumulatorChannel),
AggSrcDst: make(preprocess.AccumulatorChannel),
}
sql := data.NewSQLRead(cmd.DbNameClusterData, cmd.DeltaTClusterData)
sql.ReadFromDb(acc_c_receive)
acc_c_send := process.UpdateFeatureSpaceBuilder(subspace_channel_containers, sorter)
preprocess.WindowTimeSlideSimulator(acc_c_receive, acc_c_send, cmd.DeltaTClusterData)
<-done
// ch := make(chan preprocess.PacketData)
// BootServer(http_data)
}
}