c3a87e7df8bfd7eca64ef8a3d019c619d098960c

Author
Marc Cornellà <marc.cornella@live.com>
Committer
GitHub <noreply@github.com>
Date

Message

Add FirewallD plugin (#5386)

Diff

 1diff --git a/plugins/firewalld/firewalld.plugin.zsh b/plugins/firewalld/firewalld.plugin.zsh
 2new file mode 100644
 3index 0000000000000000000000000000000000000000..bfbf6f48fd58102698305b1bda69001934c4f7a8
 4--- /dev/null
 5+++ b/plugins/firewalld/firewalld.plugin.zsh
 6@@ -0,0 +1,17 @@
 7+alias fw="sudo firewall-cmd"
 8+alias fwp="sudo firewall-cmd --permanent"
 9+alias fwr="sudo firewall-cmd --reload"
10+alias fwrp="sudo firewall-cmd --runtime-to-permanent"
11+
12+function fwl () {
13+  # converts output to zsh array ()
14+  # @f flag split on new line
15+  zones=("${(@f)$(sudo firewall-cmd --get-active-zones | grep -v interfaces)}")
16+
17+  for i in $zones; do
18+    sudo firewall-cmd --zone $i --list-all
19+  done
20+
21+  echo 'Direct Rules:'
22+  sudo firewall-cmd --direct --get-all-rules
23+}
24diff --git a/plugins/firewalld/readme.md b/plugins/firewalld/readme.md
25new file mode 100644
26index 0000000000000000000000000000000000000000..8b5bc74d45c76cd776b4a937a44802a64349ff3d
27--- /dev/null
28+++ b/plugins/firewalld/readme.md
29@@ -0,0 +1,22 @@
30+# FirewallD Plugin
31+
32+This plugin adds some aliases and functions for FirewallD using the `firewalld-cmd` command. To use it, add firewalld to your plugins array.
33+
34+```zsh
35+plugins=(... firewalld)
36+```
37+
38+## Aliases
39+
40+| Alias | Command                                    | Description                  |
41+| :---- | :----------------------------------------- | :--------------------------- |
42+| fw    | `sudo firewall-cmd`                        | Shorthand                    |
43+| fwr   | `sudo firewall-cmd --reload`               | Reload current configuration |
44+| fwp   | `sudo firewall-cmd --permanent`            | Create permanent rule        |
45+| fwrp  | `sudo firewall-cmd --runtime-to-permanent` | Save current configuration   |
46+
47+## Functions
48+
49+| Function | Description                                                |
50+| :------- | :--------------------------------------------------------- |
51+| fwl      | Lists configuration from all active zones and direct rules |