mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Improving the security data
This commit is contained in:
parent
34b5b69231
commit
bd078f0a0e
@ -1,15 +0,0 @@
|
|||||||
package security
|
|
||||||
|
|
||||||
import ()
|
|
||||||
|
|
||||||
func Fetch() map[string]string {
|
|
||||||
data := make(map[string]string)
|
|
||||||
|
|
||||||
data["Dns"] = DnsServers()
|
|
||||||
data["Enabled"] = FirewallState()
|
|
||||||
data["Encryption"] = WifiEncryption()
|
|
||||||
data["Network"] = WifiName()
|
|
||||||
data["Stealth"] = FirewallStealthState()
|
|
||||||
|
|
||||||
return data
|
|
||||||
}
|
|
35
security/security_data.go
Normal file
35
security/security_data.go
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
package security
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SecurityData struct {
|
||||||
|
Dns string
|
||||||
|
FirewallEnabled string
|
||||||
|
FirewallStealth string
|
||||||
|
WifiEncryption string
|
||||||
|
WifiName string
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewSecurityData() *SecurityData {
|
||||||
|
return &SecurityData{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (data *SecurityData) DnsAt(idx int) string {
|
||||||
|
records := strings.Split(data.Dns, "\n")
|
||||||
|
|
||||||
|
if len(records) > 0 && len(records) > idx {
|
||||||
|
return records[idx]
|
||||||
|
} else {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (data *SecurityData) Fetch() {
|
||||||
|
data.Dns = DnsServers()
|
||||||
|
data.FirewallEnabled = FirewallState()
|
||||||
|
data.FirewallStealth = FirewallStealthState()
|
||||||
|
data.WifiName = WifiName()
|
||||||
|
data.WifiEncryption = WifiEncryption()
|
||||||
|
}
|
@ -2,7 +2,6 @@ package security
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gdamore/tcell"
|
"github.com/gdamore/tcell"
|
||||||
@ -34,7 +33,8 @@ func (widget *Widget) Refresh() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
data := Fetch()
|
data := NewSecurityData()
|
||||||
|
data.Fetch()
|
||||||
|
|
||||||
widget.View.SetTitle(" 🤺 Security ")
|
widget.View.SetTitle(" 🤺 Security ")
|
||||||
widget.RefreshedAt = time.Now()
|
widget.RefreshedAt = time.Now()
|
||||||
@ -57,20 +57,15 @@ func (widget *Widget) addView() {
|
|||||||
widget.View = view
|
widget.View = view
|
||||||
}
|
}
|
||||||
|
|
||||||
func (widget *Widget) contentFrom(data map[string]string) string {
|
func (widget *Widget) contentFrom(data *SecurityData) string {
|
||||||
str := " [red]WiFi[white]\n"
|
|
||||||
str = str + fmt.Sprintf(" %8s: %s\n", "Network", data["Network"])
|
|
||||||
str = str + fmt.Sprintf(" %8s: %s\n", "Crypto", data["Encryption"])
|
|
||||||
str = str + "\n"
|
|
||||||
str = str + " [red]Firewall[white]\n"
|
|
||||||
str = str + fmt.Sprintf(" %8s: %s\n", "Enabled", data["Enabled"])
|
|
||||||
str = str + fmt.Sprintf(" %8s: %s\n", "Stealth", data["Stealth"])
|
|
||||||
str = str + "\n"
|
|
||||||
str = str + " [red]DNS[white]\n"
|
|
||||||
|
|
||||||
for _, record := range strings.Split(data["Dns"], "\n") {
|
str := " [red]WiFi[white]\n"
|
||||||
str = str + fmt.Sprintf(" %8s\n", record)
|
str = str + fmt.Sprintf(" %8s: %s\n", "Network", data.WifiName)
|
||||||
}
|
str = str + fmt.Sprintf(" %8s: %s\n", "Crypto", data.WifiEncryption)
|
||||||
|
str = str + "\n"
|
||||||
|
str = str + " [red]Firewall[white] [red]DNS[white]\n"
|
||||||
|
str = str + fmt.Sprintf(" %8s: %4s %12s\n", "Enabled", data.FirewallEnabled, data.DnsAt(0))
|
||||||
|
str = str + fmt.Sprintf(" %8s: %4s %12s\n", "Stealth", data.FirewallStealth, data.DnsAt(1))
|
||||||
|
|
||||||
return str
|
return str
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user