Skip to content

Commit

Permalink
rdr: fix _jail > TARGET + alphabetical option order
Browse files Browse the repository at this point in the history
  • Loading branch information
tschettervictor authored Jan 8, 2025
1 parent 2da817e commit eee99a3
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions usr/local/share/bastille/rdr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ EOF
}

check_jail_validity() {

# Validate jail network type and set IP4/6
if [ "$( bastille config ${TARGET} get vnet )" != 'enabled' ]; then
_ip4_interfaces="$(bastille config ${TARGET} get ip4.addr | sed 's/,/ /g')"
_ip6_interfaces="$(bastille config ${TARGET} get ip6.addr | sed 's/,/ /g')"
Expand Down Expand Up @@ -218,6 +220,15 @@ while [ "$#" -gt 0 ]; do
-h|--help|help)
usage
;;
-d|--destination)
if ifconfig | grep -owq "inet ${2}"; then
OPTION_DST=1
RDR_DST="${2}"
shift 2
else
error_exit "${2} is not an IP on this system."
fi
;;
-i|--interface)
if ifconfig | grep -owq "${2}:"; then
OPTION_IF=1
Expand All @@ -233,15 +244,6 @@ while [ "$#" -gt 0 ]; do
RDR_SRC="${2}"
shift 2
;;
-d|--destination)
if ifconfig | grep -owq "inet ${2}"; then
OPTION_DST=1
RDR_DST="${2}"
shift 2
else
error_exit "${2} is not an IP on this system."
fi
;;
-t|--type)
if [ "${2}" != "ipv4" ] && [ "${2}" != "ipv6" ]; then
error_exit "[-t|--type] must be [ipv4|ipv6]"
Expand Down Expand Up @@ -296,8 +298,8 @@ while [ "$#" -gt 0 ]; do
usage
else
check_jail_validity
echo "${_jail} redirects:"
pfctl -a "rdr/${_jail}" -Fn
echo "${TARGET} redirects:"
pfctl -a "rdr/${TARGET}" -Fn
fi
shift
;;
Expand All @@ -308,10 +310,10 @@ while [ "$#" -gt 0 ]; do
usage
else
check_jail_validity
echo "${_jail} redirects:"
pfctl -a "rdr/${_jail}" -Fn
echo "${TARGET} redirects:"
pfctl -a "rdr/${TARGET}" -Fn
if rm -f "${bastille_jailsdir}/${_jail}/rdr.conf"; then
info "[${_jail}]: rdr.conf removed"
info "[${TARGET}]: rdr.conf removed"
fi
fi
shift
Expand Down

0 comments on commit eee99a3

Please sign in to comment.