mirror of
https://github.com/hackacad/bastille.git
synced 2026-01-02 18:58:11 +01:00
error handling
This commit is contained in:
@@ -224,40 +224,44 @@ RDR_DST="any"
|
||||
OPTION="0"
|
||||
|
||||
# Check for options
|
||||
case "$1" in
|
||||
-i|--interface)
|
||||
if [ -z "${2}" ]; then
|
||||
error_exit "Must specify an interface with [-i|--interface]"
|
||||
fi
|
||||
if ifconfig | grep -owq "${2}:"; then
|
||||
RDR_IF="${2}"
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
-i|--interface)
|
||||
if [ -z "${2}" ]; then
|
||||
error_exit "Must specify an interface with [-i|--interface]"
|
||||
fi
|
||||
if ifconfig | grep -owq "${2}:"; then
|
||||
RDR_IF="${2}"
|
||||
OPTION="1"
|
||||
shift 2
|
||||
else
|
||||
error_exit "${2} is not a valid interface."
|
||||
fi
|
||||
;;
|
||||
-s|--source)
|
||||
if [ -z "${2}" ]; then
|
||||
error_exit "Must specify a source IP/subnet with [-s|--source]"
|
||||
fi
|
||||
check_rdr_ip_validity "${2}"
|
||||
RDR_SRC="${2}"
|
||||
OPTION="1"
|
||||
shift 2
|
||||
else
|
||||
error_exit "${2} is not a valid interface."
|
||||
fi
|
||||
;;
|
||||
-s|--source)
|
||||
if [ -z "${2}" ]; then
|
||||
error_exit "Must specify a source IP/subnet with [-s|--source]"
|
||||
fi
|
||||
check_ip_validity "${2}"
|
||||
RDR_SRC="${2}"
|
||||
OPTION="1"
|
||||
shift 2
|
||||
;;
|
||||
-d|--destination)
|
||||
if [ -z "${2}" ]; then
|
||||
error_exit "Must specify a destination IP with [-d|--destination]"
|
||||
fi
|
||||
if ifconfig | grep -owq "inet ${2}"; then
|
||||
RDR_DST="${2}"
|
||||
OPTION="1"
|
||||
shift 2
|
||||
else
|
||||
error_exit "${2} is not an IP on this system."
|
||||
fi
|
||||
;;
|
||||
;;
|
||||
-d|--destination)
|
||||
if [ -z "${2}" ]; then
|
||||
error_exit "Must specify a destination IP with [-d|--destination]"
|
||||
fi
|
||||
if ifconfig | grep -owq "inet ${2}"; then
|
||||
RDR_DST="${2}"
|
||||
OPTION="1"
|
||||
shift 2
|
||||
else
|
||||
error_exit "${2} is not an IP on this system."
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ $# -lt 2 ]; then
|
||||
|
||||
Reference in New Issue
Block a user