Ultima attività 1 month ago

Revisione 2d3bb954d2ecc513096278330f9628cbc38f59f8

gistfile1.txt Raw
1function cmd::fw::list() {
2 local peer="" type=""
3 while [[ $# -gt 0 ]]; do
4 case "$1" in
5 --peer) peer="$2"; shift 2 ;;
6 --type) type="$2"; shift 2 ;;
7 *) shift ;;
8 esac
9 done
10
11 log::section "Firewall Rules (FORWARD)"
12
13 if [[ -n "$peer" ]]; then
14 local ip
15 ip=$(peers::get_ip "$peer")
16 [[ -z "$ip" ]] && log::error "Peer not found: $peer" && return 1
17 printf "\n"
18 iptables -L FORWARD -n -v | grep -F "$ip"
19 printf "\n"
20 elif [[ -n "$type" ]]; then
21 local subnet
22 subnet=$(config::subnet_for "$type")
23 [[ -z "$subnet" ]] && log::error "Unknown type: $type" && return 1
24 printf "\n"
25 iptables -L FORWARD -n -v | grep -F "$subnet"
26 printf "\n"
27 else
28 printf "\n"
29 iptables -L FORWARD -n -v | grep -v "^Chain\|^target\|^$\|ACCEPT.*0\.0\.0\.0.*0\.0\.0\.0"
30 printf "\n"
31 fi
32}
33
34function cmd::fw::nat() {
35 log::section "NAT Rules (PREROUTING)"
36 iptables -t nat -L PREROUTING -n -v
37}