From 8b3d3cc91daa6e8372a1bd005ff990afc540cd1f Mon Sep 17 00:00:00 2001 From: TheRedSpy15 Date: Fri, 12 Oct 2018 10:40:45 -0400 Subject: [PATCH 1/7] Added firewall status on linux --- security/firewall.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/security/firewall.go b/security/firewall.go index 6323b5e1..5af98131 100644 --- a/security/firewall.go +++ b/security/firewall.go @@ -4,6 +4,7 @@ import ( "os/exec" "runtime" "strings" + "bytes" "github.com/senorprogrammer/wtf/wtf" ) @@ -36,8 +37,21 @@ func FirewallStealthState() string { /* -------------------- Unexported Functions -------------------- */ -func firewallStateLinux() string { - return "[red]NA[white]" +func firewallStateLinux() string { // might be very Ubuntu specific + cmd := exec.Command("ufw, "status") + var o bytes.Buffer + + cmd.Stdout = &o + + if err := cmd.Run(); err != nil { + panic(err.Error()) + } + + if strings.Contains(o.String(), "active") { + return "[green]Enabled[white]" + } else { + return "[red]Disabled[white]" + } } func firewallStateMacOS() string { From 7b422cc3f36a0e16b635170220aae73a081e78d6 Mon Sep 17 00:00:00 2001 From: TheRedSpy15 Date: Sun, 14 Oct 2018 20:35:37 -0400 Subject: [PATCH 2/7] Update firewall.go --- security/firewall.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security/firewall.go b/security/firewall.go index 5af98131..34c8b4c6 100644 --- a/security/firewall.go +++ b/security/firewall.go @@ -44,7 +44,7 @@ func firewallStateLinux() string { // might be very Ubuntu specific cmd.Stdout = &o if err := cmd.Run(); err != nil { - panic(err.Error()) + return "[red]NA[white] } if strings.Contains(o.String(), "active") { From c3baf05b20dac6009ff1a5f4dc9737cc754f681d Mon Sep 17 00:00:00 2001 From: TheRedSpy15 Date: Sun, 14 Oct 2018 20:44:10 -0400 Subject: [PATCH 3/7] only get linux firewall if root --- security/firewall.go | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/security/firewall.go b/security/firewall.go index 34c8b4c6..ab8bdf3c 100644 --- a/security/firewall.go +++ b/security/firewall.go @@ -5,6 +5,7 @@ import ( "runtime" "strings" "bytes" + "os/user" "github.com/senorprogrammer/wtf/wtf" ) @@ -38,19 +39,23 @@ func FirewallStealthState() string { /* -------------------- Unexported Functions -------------------- */ func firewallStateLinux() string { // might be very Ubuntu specific - cmd := exec.Command("ufw, "status") - var o bytes.Buffer + user, _ := user.Current() + + if (strings.Contains(user.Username, "root") { + cmd := exec.Command("ufw, "status") + var o bytes.Buffer - cmd.Stdout = &o + cmd.Stdout = &o - if err := cmd.Run(); err != nil { - return "[red]NA[white] - } + 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]" + if strings.Contains(o.String(), "active") { + return "[green]Enabled[white]" + } else { + return "[red]Disabled[white]" + } } } From 9f9c124f9fcf4afb4b53bf777588d2f1fb0aa28e Mon Sep 17 00:00:00 2001 From: TheRedSpy15 Date: Sun, 14 Oct 2018 20:55:27 -0400 Subject: [PATCH 4/7] syntax fixes --- security/firewall.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/security/firewall.go b/security/firewall.go index ab8bdf3c..75e80a07 100644 --- a/security/firewall.go +++ b/security/firewall.go @@ -40,15 +40,14 @@ func FirewallStealthState() string { func firewallStateLinux() string { // might be very Ubuntu specific user, _ := user.Current() - - if (strings.Contains(user.Username, "root") { - cmd := exec.Command("ufw, "status") + + 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] + return "[red]NA[white]" } if strings.Contains(o.String(), "active") { @@ -56,6 +55,8 @@ func firewallStateLinux() string { // might be very Ubuntu specific } else { return "[red]Disabled[white]" } + } else { + return "[red]NA[white]" } } From 7d9dd56aaae53c34e8efe85a597a364a95341f35 Mon Sep 17 00:00:00 2001 From: Mathias Weber Date: Mon, 15 Oct 2018 22:51:35 +0200 Subject: [PATCH 5/7] add static hot key assignments for text widgets --- wtf/focus_tracker.go | 18 +++++++++++++++++- wtf/text_widget.go | 12 +++++++++--- 2 files changed, 26 insertions(+), 4 deletions(-) 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)), } From d48f8a114412ca8d332a023d17fba9ab5a64bfef Mon Sep 17 00:00:00 2001 From: Chris Cummer Date: Wed, 17 Oct 2018 19:06:28 -0700 Subject: [PATCH 6/7] Add @TheRedSpy15 as a contributor --- .all-contributorsrc | 7 +++++++ README.md | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) 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/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 From 6a3c39970c2315841b7afc287b887bea9dd15439 Mon Sep 17 00:00:00 2001 From: Chris Cummer Date: Wed, 17 Oct 2018 19:28:00 -0700 Subject: [PATCH 7/7] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) 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