Naposledy aktivní 1 month ago

gistfile1.txt Raw
1function fw::has_rule() {
2 # Generic rule existence check
3 # fw::has_rule <target> <client_ip> <dest> [port] [proto]
4 local action="${1:-DROP}" client_ip="${2:-}" target="${3:-}" \
5 port="${4:-}" proto="${5:-}"
6 if [[ -n "$port" ]]; then
7 fw::_forward_exists -s "$client_ip" -d "$target" \
8 -p "$proto" --dport "$port" -j "$action"
9 else
10 fw::_forward_exists -s "$client_ip" -d "$target" -j "$action"
11 fi
12}
13
14function fw::has_block_rule() {
15 fw::has_rule "DROP" "$@"
16}
17
18function fw::has_allow_rule() {
19 fw::has_rule "ACCEPT" "$@"
20}