mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
* WTF-730 Fix missing color key config error Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-730 Add Subheading color formatting to modules Users can now set a `subheading` color in their config to change the color of subheadings in widget display. Defaults to `red`. Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-730 Fix oustanding color issues Clean up missing color config changes not addressed in earlier commits. Signed-off-by: Chris Cummer <chriscummer@me.com> * Remove unused dependency Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-730 Base cleanup Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-730 Fix a few bugs related to color config changes Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-730 Fix issues with PagerDuty subheading display Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-730 Fix bug with Todo list colour rendering Signed-off-by: Chris Cummer <chriscummer@me.com>
75 lines
1.7 KiB
Go
75 lines
1.7 KiB
Go
package security
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/rivo/tview"
|
|
"github.com/wtfutil/wtf/view"
|
|
)
|
|
|
|
type Widget struct {
|
|
view.TextWidget
|
|
|
|
settings *Settings
|
|
}
|
|
|
|
func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
|
widget := Widget{
|
|
TextWidget: view.NewTextWidget(app, settings.common),
|
|
|
|
settings: settings,
|
|
}
|
|
|
|
return &widget
|
|
}
|
|
|
|
/* -------------------- Exported Functions -------------------- */
|
|
|
|
func (widget *Widget) Refresh() {
|
|
|
|
if widget.Disabled() {
|
|
return
|
|
}
|
|
|
|
widget.Redraw(widget.content)
|
|
}
|
|
|
|
/* -------------------- Unexported Functions -------------------- */
|
|
|
|
func (widget *Widget) content() (string, string, bool) {
|
|
data := NewSecurityData()
|
|
data.Fetch()
|
|
str := fmt.Sprintf(" [%s]WiFi[white]\n", widget.settings.common.Colors.Subheading)
|
|
str += fmt.Sprintf(" %8s: %s\n", "Network", data.WifiName)
|
|
str += fmt.Sprintf(" %8s: %s\n", "Crypto", data.WifiEncryption)
|
|
str += "\n"
|
|
|
|
str += fmt.Sprintf(" [%s]Firewall[white]\n", widget.settings.common.Colors.Subheading)
|
|
str += fmt.Sprintf(" %8s: %4s\n", "Status", data.FirewallEnabled)
|
|
str += fmt.Sprintf(" %8s: %4s\n", "Stealth", data.FirewallStealth)
|
|
str += "\n"
|
|
|
|
str += fmt.Sprintf(" [%s]Users[white]\n", widget.settings.common.Colors.Subheading)
|
|
str += fmt.Sprintf(" %s", strings.Join(data.LoggedInUsers, "\n "))
|
|
str += "\n\n"
|
|
|
|
str += fmt.Sprintf(" [%s]DNS[white]\n", widget.settings.common.Colors.Subheading)
|
|
str += fmt.Sprintf(" %12s\n", data.DnsAt(0))
|
|
str += fmt.Sprintf(" %12s\n", data.DnsAt(1))
|
|
str += "\n"
|
|
|
|
return widget.CommonSettings().Title, str, false
|
|
}
|
|
|
|
func (widget *Widget) labelColor(label string) string {
|
|
switch label {
|
|
case "on":
|
|
return "green"
|
|
case "off":
|
|
return "red"
|
|
default:
|
|
return "white"
|
|
}
|
|
}
|