-
-
Save dazuelos/3978acf5c3193ce78f3217ff8c061a29 to your computer and use it in GitHub Desktop.
script to dump PF status
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# print an anchor subset (r, n or A) | |
function pfprint() { | |
# avoid trusting PATH and . | |
/usr/bin/sudo pfctl -a "$2" -s"$1" 2>/dev/null | |
} | |
# print a full anchor content | |
function pfprint_all() { | |
# print the anchor name on 1st line, and all content indented | |
local anchor=$(printf "%-40s" ${1:-"/"}) | |
local indent=$(printf "%-40s") | |
( | |
pfprint r "$1" | sed "s,^,r ," | |
pfprint n "$1" | sed "s,^,n ," | |
pfprint A "$1" | sed "s,^,A ," | |
) | sed -e "1s,^,${anchor}," -e "2,\$s,^,${indent}," | |
# recursively descend the anchors tree | |
for a in $(pfprint A "$1") ; do | |
pfprint_all "$a" | |
done | |
} | |
pfprint_all |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Suppress repeated anchor name printing, and indented content of anchor
to make the structure of anchors tree visible.