-
Notifications
You must be signed in to change notification settings - Fork 5
/
ui_tab_events.go
43 lines (36 loc) · 949 Bytes
/
ui_tab_events.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 (
"sort"
"fyne.io/fyne"
"github.com/evilsocket/opensnitch/daemon/ui/protocol"
)
const eventsTabRows = 20
func makeEventsTab() fyne.Widget {
headers := []string{"Time", "Action", "Process", "Destination", "Protocol", "Rule"}
tbl := newTableWithHeaders(eventsTabRows, len(headers))
tbl.SetHeaders(headers)
return tbl
}
func eventsTabData(stats *protocol.Statistics) [][]string {
events := stats.GetEvents()
l := len(events)
rows := eventsTabRows
if l < eventsTabRows {
rows = l
}
sort.Slice(events, func(i, j int) bool {
return events[i].GetTime() > events[j].GetTime()
})
var data [][]string
for i := 0; i < rows; i++ {
data = append(data, []string{
events[i].GetTime(),
events[i].GetRule().GetAction(),
events[i].GetConnection().GetProcessPath(),
events[i].GetConnection().GetDstHost(),
events[i].GetConnection().GetProtocol(),
events[i].GetRule().GetName(),
})
}
return data
}