forked from aslanvaroqua/network-topology
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
69 lines (50 loc) · 1.14 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
package main
import (
"log"
"flag"
"os"
"github.com/google/gopacket/pcap"
"github.com/aslanvaroqua/skewu/clockview"
"github.com/aslanvaroqua/skewu/clockskew"
)
func handleDevice(device string) {
flag := false
devices, err := pcap.FindAllDevs()
if err != nil {
log.Fatal(err)
}
for _, dev := range devices{
if device == dev.Name{
flag = true
}
}
if flag == false{
log.Fatalln("[ERROR] not found device ", device)
}
}
func handleBPFFilter(device, bpFilter, storageFile string) {
clockskew.BpConfig = bpFilter
clockskew.DeviceName = device
}
func handleHelp(displayHelp bool) {
if displayHelp {
flag.Usage()
os.Exit(0)
}
}
func init(){
clockskew.ClockChannel = make(chan clockskew.Clock, 1000)
device := flag.String("e", "eth0", "device name")
help := flag.Bool("h", false, "help")
bpFilter := flag.String("filter", "tcp", "bpFilter")
storageFile := flag.String("f", "storage.csv", "storage file")
flag.Parse()
handleHelp(*help)
handleDevice(*device)
handleBPFFilter(*device, *bpFilter, *storageFile)
}
func main() {
go clockskew.MongoStorage()
//go clockskew.SendClockSkew()
clockskew.CapturePacket()
}