mirror of
https://gitlab.com/shorewall/code.git
synced 2025-01-11 08:08:12 +01:00
Edit ip addresses a bit better in interactive commands
git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@5144 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb
This commit is contained in:
parent
2cbb02649c
commit
5e7efa2975
@ -360,6 +360,32 @@ lib_avail() # $1 = Name of the Library
|
||||
|
||||
LEFTSHIFT='<<'
|
||||
|
||||
#
|
||||
# Validate an IP address
|
||||
#
|
||||
valid_address() {
|
||||
local x y
|
||||
local ifs=$IFS
|
||||
|
||||
IFS=.
|
||||
|
||||
for x in $1; do
|
||||
case $x in
|
||||
[0-9]|[0-9][0-9]|[1-2][0-9][0-9])
|
||||
[ $x -lt 256 ] || { IFS=$ifs; return 2; }
|
||||
;;
|
||||
*)
|
||||
IFS=$ifs
|
||||
return 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
IFS=$ifs
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#
|
||||
# Convert an IP address in dot quad format to an integer
|
||||
#
|
||||
|
@ -1468,6 +1468,7 @@ case "$COMMAND" in
|
||||
usage 1
|
||||
fi
|
||||
|
||||
valid_address $address || fatal_error "Invalid IP address: $address"
|
||||
[ -z "$vlsm" ] && exit 2
|
||||
[ "x$address" = "x$vlsm" ] && usage 2
|
||||
[ $vlsm -gt 32 ] && echo "Invalid VLSM: /$vlsm" >&2 && exit 2
|
||||
@ -1484,6 +1485,10 @@ case "$COMMAND" in
|
||||
[ -n "$debugging" ] && set -x
|
||||
case $2 in
|
||||
*.*.*.*-*.*.*.*)
|
||||
for address in ${2%-*} ${2#*-}; do
|
||||
valid_address $address || fatal_error "Invalid IP address: $address"
|
||||
done
|
||||
|
||||
ip_range $2
|
||||
;;
|
||||
*)
|
||||
@ -1495,6 +1500,7 @@ case "$COMMAND" in
|
||||
[ -n "$debugging" ] && set -x
|
||||
case $2 in
|
||||
*.*.*.*)
|
||||
valid_address $2 || fatal_error "Invalid IP address: $2"
|
||||
echo " $(decodeaddr $2)"
|
||||
;;
|
||||
*)
|
||||
@ -1504,7 +1510,7 @@ case "$COMMAND" in
|
||||
;;
|
||||
restore)
|
||||
shift
|
||||
r estore_command $@
|
||||
restore_command $@
|
||||
;;
|
||||
call)
|
||||
[ -n "$debugging" ] && set -x
|
||||
|
Loading…
Reference in New Issue
Block a user