-
Notifications
You must be signed in to change notification settings - Fork 5
/
ui_tab_general.go
38 lines (32 loc) · 909 Bytes
/
ui_tab_general.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
package main
import (
"fmt"
"time"
"fyne.io/fyne"
"github.com/evilsocket/opensnitch/daemon/ui/protocol"
)
var generalStatsDefaultValues = [][]string{[]string{"-", "waiting for connection", "0", "0", "0", "0"}}
func makeGeneralTab() fyne.Widget {
headers := []string{"Version", "Daemon Status", "Uptime", "Rules", "Connections", "Dropped"}
tbl := newTableWithHeaders(1, len(headers))
tbl.SetHeaders(headers)
tbl.SetData(generalStatsDefaultValues)
return tbl
}
func generalTabData(stats *protocol.Statistics) [][]string {
status := "running"
if stats.GetUptime() == 0 {
status = "waiting for connection"
}
uptime := time.Duration(int(stats.GetUptime())) * time.Second
return [][]string{
{
stats.GetDaemonVersion(),
status,
uptime.String(),
fmt.Sprintf("%d", stats.GetRules()),
fmt.Sprintf("%d", stats.GetConnections()),
fmt.Sprintf("%d", stats.GetDropped()),
},
}
}