-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
70 lines (65 loc) · 1.64 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
package main
import (
"fmt"
"os"
"sync"
"github.com/opennetworktools/netmon/internal"
)
func main() {
c := make(chan internal.CPacket)
m := internal.NewHostMap()
mc := make(chan internal.CHost)
var wg sync.WaitGroup
args := os.Args
if len(args) == 1 {
fmt.Println("No command entered!")
} else if args[1] == "show" || args[1] == "sh" {
if args[2] == "interface" || args[2] == "int" {
if len(args) >= 5 {
if args[3] == "describe" || args[3] == "des" {
internal.FindInterfaceDescribe(args[4])
}
}
} else if args[2] == "interfaces" || args[2] == "ints" {
if len(args) >= 4 {
if args[3] == "describe" || args[3] == "des" {
internal.FindAllInterfacesDescribe()
}
return
}
internal.FindAllInterfaces()
} else if args[2] == "ip" {
internal.GetLocalIP()
}
} else if args[1] == "watch" {
if args[2] == "packets" {
if len(args) >= 5 {
if args[4] == "html" {
wg.Add(2)
go internal.WatchInterface(args[3], c)
go internal.ResolveHostsInformation(args[3], c, m, mc, true)
// go internal.StartServer(c, m)
wg.Wait()
} else if args[4] == "web" {
wg.Add(3)
go internal.WatchInterface(args[3], c)
go internal.ResolveHostsInformation(args[3], c, m, mc, true)
go internal.SendEvents(c, mc)
wg.Wait()
}
} else {
wg.Add(2)
go internal.WatchInterface(args[3], c)
go internal.PrintPacket(c)
wg.Wait()
}
} else if args[2] == "hosts" {
wg.Add(2)
go internal.WatchInterface(args[3], c)
go internal.ResolveHostsInformation(args[3], c, m, mc, false)
wg.Wait()
}
} else {
fmt.Printf("Command %v not found!\n", args[2])
}
}