diff --git a/.all-contributorsrc b/.all-contributorsrc index 99c5bd71..37c7021f 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -344,6 +344,13 @@ "name": "Mathias Weber", "avatar_url": "https://avatars2.githubusercontent.com/u/882006?v=4", "profile": "https://github.com/mweb", + "contributions": [] + }, + { + "login": "TheRedSpy15", + "name": "TheRedSpy15", + "avatar_url": "https://avatars1.githubusercontent.com/u/32081703?v=4", + "profile": "https://github.com/TheRedSpy15", "contributions": [ ] } diff --git a/CHANGELOG.md b/CHANGELOG.md index 114d7680..d6cb5f14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ ### ⚡️ Added * Mecurial module added (@mweb) +* Can now define numeric hotkeys in config (@mweb) +* Linux firewall support added (@TheRedSpy15) ### 🐞 Fixed diff --git a/README.md b/README.md index 792275b9..dda0ead9 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-48-orange.svg?style=flat-square)](#contributors) +[![All Contributors](https://img.shields.io/badge/all_contributors-49-orange.svg?style=flat-square)](#contributors) [![Build Status](https://travis-ci.com/senorprogrammer/wtf.svg?branch=master)](https://travis-ci.com/senorprogrammer/wtf) [![Gitter Chat](https://badges.gitter.im/wtfutil/Lobby.svg)](https://gitter.im/wtfutil/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Twitter](https://img.shields.io/badge/follow-on%20twitter-blue.svg)](https://twitter.com/wtfutil) @@ -71,6 +71,7 @@ project: | [
Lineu Felipe](https://github.com/darkSasori)
| [
Konstantin](https://github.com/kvj)
| [
Brendan O'Leary](http://www.brendanoleary.com)
| [
bertl4398](https://github.com/bertl4398)
| [
Ferenc-](https://github.com/Ferenc-)
| [
Rohan Verma](http://rohanverma.net)
| | [
Tim Fitzgerald](https://github.com/fimtitzgerald)
| [
Federico Ruggi](https://github.com/ruggi)
| [
Craig Woodward](https://github.com/ctwoodward)
| [
ReadmeCritic](https://twitter.com/ReadmeCritic)
| [
Eugene](https://github.com/jdevelop)
| [
Kenny Wu](https://github.com/Trinergy)
| | [
Renán Romero](http://www.romeroruiz.com)
| [
Bastian Groß](https://github.com/sticreations)
| [
nicholas-eden](https://github.com/nicholas-eden)
| [
Dan Rabinowitz](https://github.com/danrabinowitz)
| [
David Missmann](https://github.com/dvdmssmnn)
| [
Mathias Weber](https://github.com/mweb)
| +| [
TheRedSpy15](https://github.com/TheRedSpy15)
| ## Acknowledgments diff --git a/security/firewall.go b/security/firewall.go index 6323b5e1..75e80a07 100644 --- a/security/firewall.go +++ b/security/firewall.go @@ -4,6 +4,8 @@ import ( "os/exec" "runtime" "strings" + "bytes" + "os/user" "github.com/senorprogrammer/wtf/wtf" ) @@ -36,8 +38,26 @@ func FirewallStealthState() string { /* -------------------- Unexported Functions -------------------- */ -func firewallStateLinux() string { - return "[red]NA[white]" +func firewallStateLinux() string { // might be very Ubuntu specific + user, _ := user.Current() + + if strings.Contains(user.Username, "root") { + cmd := exec.Command("ufw", "status") + + var o bytes.Buffer + cmd.Stdout = &o + if err := cmd.Run(); err != nil { + return "[red]NA[white]" + } + + if strings.Contains(o.String(), "active") { + return "[green]Enabled[white]" + } else { + return "[red]Disabled[white]" + } + } else { + return "[red]NA[white]" + } } func firewallStateMacOS() string { diff --git a/wtf/focus_tracker.go b/wtf/focus_tracker.go index 06b1f16c..b7296f01 100644 --- a/wtf/focus_tracker.go +++ b/wtf/focus_tracker.go @@ -29,9 +29,25 @@ func (tracker *FocusTracker) AssignHotKeys() { return } + usedKeys := make(map[string]bool) + focusables := tracker.focusables() i := 1 - for _, focusable := range tracker.focusables() { + for _, focusable := range focusables { + if focusable.FocusChar() != "" { + usedKeys[focusable.FocusChar()] = true + } + } + for _, focusable := range focusables { + if focusable.FocusChar() != "" { + continue + } + if _, foundKey := usedKeys[string('0'+i)]; foundKey { + for ; foundKey; _, foundKey = usedKeys[string('0'+i)] { + i++ + } + } + // Don't have nav characters > "9" if i >= 10 { break diff --git a/wtf/text_widget.go b/wtf/text_widget.go index 3ca58480..1e661e9b 100644 --- a/wtf/text_widget.go +++ b/wtf/text_widget.go @@ -22,10 +22,16 @@ type TextWidget struct { } func NewTextWidget(app *tview.Application, name string, configKey string, focusable bool) TextWidget { - widget := TextWidget{ - enabled: Config.UBool(fmt.Sprintf("wtf.mods.%s.enabled", configKey), false), - focusable: focusable, + focusCharValue := Config.UInt(fmt.Sprintf("wtf.mods.%s.focusChar", configKey), -1) + focusChar := string('0' + focusCharValue) + if focusCharValue == -1 { + focusChar = "" + } + widget := TextWidget{ + enabled: Config.UBool(fmt.Sprintf("wtf.mods.%s.enabled", configKey), false), + focusable: focusable, + focusChar: focusChar, Name: Config.UString(fmt.Sprintf("wtf.mods.%s.title", configKey), name), RefreshInt: Config.UInt(fmt.Sprintf("wtf.mods.%s.refreshInterval", configKey)), }