function fw::has_rule() { # Generic rule existence check # fw::has_rule [port] [proto] local action="${1:-DROP}" client_ip="${2:-}" target="${3:-}" \ port="${4:-}" proto="${5:-}" if [[ -n "$port" ]]; then fw::_forward_exists -s "$client_ip" -d "$target" \ -p "$proto" --dport "$port" -j "$action" else fw::_forward_exists -s "$client_ip" -d "$target" -j "$action" fi } function fw::has_block_rule() { fw::has_rule "DROP" "$@" } function fw::has_allow_rule() { fw::has_rule "ACCEPT" "$@" }