From ae39ededbb57d0adf3c5eac83bbcf549f0798444 Mon Sep 17 00:00:00 2001 From: tschettervictor <85497460+tschettervictor@users.noreply.github.com> Date: Wed, 18 Jun 2025 18:56:02 -0600 Subject: [PATCH] rdr: Allow setting table name as source --- usr/local/share/bastille/rdr.sh | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/usr/local/share/bastille/rdr.sh b/usr/local/share/bastille/rdr.sh index 1cabc9e3..631a10c6 100644 --- a/usr/local/share/bastille/rdr.sh +++ b/usr/local/share/bastille/rdr.sh @@ -108,6 +108,17 @@ check_rdr_ip_validity() { fi } +check_rdr_table_validity() { + + local table="${1}" + + if ! pfctl -t "${table}" -T show; then + info "\nValid: (${table})." + else + info "\nValid: (${table})." + fi +} + validate_rdr_rule() { local if="${1}" @@ -261,9 +272,14 @@ while [ "$#" -gt 0 ]; do fi ;; -s|--source) - check_rdr_ip_validity "${2}" + if echo "${2}" | grep -Eoq "([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|.*:.*"; then + check_rdr_ip_validity "${2}" + RDR_SRC="${2}" + else + check_rdr_table_validity "${2}" + RDR_SRC="$(echo "${2}" | sed -e 's/^//')" + fi OPTION_SRC=1 - RDR_SRC="${2}" shift 2 ;; -t|--type)