mirror of
https://github.com/mozilla/cipherscan.git
synced 2024-11-22 22:33:40 +01:00
Merge pull request #81 from floatingatoll/argparse_fixes
Argparse fixes
This commit is contained in:
commit
0de6abab61
29
cipherscan
29
cipherscan
@ -1397,19 +1397,26 @@ fi
|
|||||||
|
|
||||||
# echo parameters left: $@
|
# echo parameters left: $@
|
||||||
|
|
||||||
TEMPTARGET=$(sed -e 's/^.* //'<<<"${@}")
|
if (( $# < 1 )); then
|
||||||
HOST=$(sed -e 's/:.*//'<<<"${TEMPTARGET}")
|
echo "The final argument must be a valid HOST[:PORT], but none was provided." 1>&2
|
||||||
PORT=$(sed -e 's/.*://'<<<"${TEMPTARGET}")
|
exit 1
|
||||||
|
|
||||||
# Default to https if no port given
|
|
||||||
if [[ "$HOST" = "$PORT" ]]; then
|
|
||||||
PORT=443
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
debug "host: $HOST"
|
PARAMS=("$@")
|
||||||
debug "Port: $PORT"
|
TARGET=${PARAMS[-1]}
|
||||||
|
unset PARAMS[-1]
|
||||||
|
|
||||||
|
# Refuse to proceed if the hostname starts with a hyphen, since hostnames can't
|
||||||
|
# begin with a hyphen and this likely means we accidentally parsed an option as
|
||||||
|
# a hostname.
|
||||||
|
if [[ -z $TARGET || $TARGET =~ ^[-:] || $TARGET =~ :.*[^0-9] ]]; then
|
||||||
|
echo "The final argument '$TARGET' is not a valid HOST[:PORT]." 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if ! [[ $TARGET =~ : ]]; then
|
||||||
|
TARGET="${TARGET}:443"
|
||||||
|
fi
|
||||||
|
|
||||||
TARGET=$HOST:$PORT
|
|
||||||
debug "target: $TARGET"
|
debug "target: $TARGET"
|
||||||
|
|
||||||
# test our openssl is usable
|
# test our openssl is usable
|
||||||
@ -1455,7 +1462,7 @@ if [[ $VERBOSE != 0 ]] ; then
|
|||||||
$OPENSSLBIN ciphers ALL 2>/dev/null
|
$OPENSSLBIN ciphers ALL 2>/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SCLIENTARGS=$(sed -e s,${TEMPTARGET},,<<<"${@}")
|
SCLIENTARGS="${PARAMS[*]}"
|
||||||
debug "sclientargs: $SCLIENTARGS"
|
debug "sclientargs: $SCLIENTARGS"
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user