mirror of
https://github.com/mozilla/cipherscan.git
synced 2024-11-22 14:23:41 +01:00
Merge pull request #79 from floatingatoll/autodetection-perf
separate darwin and non-darwin OS autodetection, add NOAUTODETECT support for top1m performance
This commit is contained in:
commit
b951fd5588
84
cipherscan
84
cipherscan
@ -10,35 +10,60 @@
|
|||||||
|
|
||||||
DOBENCHMARK=0
|
DOBENCHMARK=0
|
||||||
BENCHMARKITER=30
|
BENCHMARKITER=30
|
||||||
DIRNAMEPATH=$(dirname "$0")
|
|
||||||
REALPATH="$DIRNAMEPATH"
|
|
||||||
# make sure this doesn't error out when readlink -f isn't available (OSX)
|
|
||||||
readlink -f "$0" &>/dev/null && REALPATH=$(dirname "$(readlink -f "$0")")
|
|
||||||
if [[ "$(uname -s)" == "Darwin" ]]; then
|
|
||||||
OPENSSLBIN="${REALPATH}/openssl-darwin64"
|
|
||||||
else
|
|
||||||
OPENSSLBIN="${REALPATH}/openssl"
|
|
||||||
fi
|
|
||||||
OPENSSLBINHELP="$($OPENSSLBIN s_client -help 2>&1)"
|
|
||||||
if ! [[ $OPENSSLBINHELP =~ -connect ]]; then
|
|
||||||
echo "$OPENSSLBIN s_client doesn't accept the -connect parameter, which is extremely strange; refusing to proceed." 1>&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# cipherscan requires bash4, which doesn't come by default in OSX
|
# cipherscan requires bash4, which doesn't come by default in OSX
|
||||||
if [[ ${BASH_VERSINFO[0]} -lt 4 ]]; then
|
if [[ ${BASH_VERSINFO[0]} -lt 4 ]]; then
|
||||||
echo "Bash version 4 is required to run cipherscan."
|
echo "Bash version 4 is required to run cipherscan." 1>&2
|
||||||
echo "Please upgrade your version of bash (ex: brew install bash)."
|
echo "Please upgrade your version of bash (ex: brew install bash)." 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -n $NOAUTODETECT ]]; then
|
||||||
|
if ! [[ -f $TIMEOUTBIN && -x $TIMEOUTBIN ]]; then
|
||||||
|
echo "NOAUTODETECT set, but TIMEOUTBIN is not an executable file" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if ! [[ -f $OPENSSLBIN && -x $OPENSSLBIN ]]; then
|
||||||
|
echo "NOAUTODETECT set, but OPENSSLBIN is not an executable file" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
case "$(uname -s)" in
|
||||||
|
Darwin)
|
||||||
|
opensslbin_name="openssl-darwin64"
|
||||||
|
|
||||||
|
READLINKBIN=$(which greadlink 2>/dev/null)
|
||||||
|
if [[ -z $READLINKBIN ]]; then
|
||||||
|
echo "greadlink not found. (try: brew install coreutils)" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
TIMEOUTBIN=$(which gtimeout 2>/dev/null)
|
||||||
|
if [[ -z $TIMEOUTBIN ]]; then
|
||||||
|
echo "gtimeout not found. (try: brew install coreutils)" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
opensslbin_name="openssl"
|
||||||
|
|
||||||
|
# test that readlink or greadlink (darwin) are present
|
||||||
|
READLINKBIN="$(which readlink)"
|
||||||
|
|
||||||
|
if [[ "$READLINKBIN" == "" ]]; then
|
||||||
|
READLINKBIN="$(which greadlink)"
|
||||||
|
if [[ "$READLINKBIN" == "" ]]; then
|
||||||
|
echo "neither readlink nor greadlink are present. install coreutils with {apt-get,yum,brew} install coreutils" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# test that timeout or gtimeout (darwin) are present
|
# test that timeout or gtimeout (darwin) are present
|
||||||
TIMEOUTBIN="$(which timeout)"
|
TIMEOUTBIN="$(which timeout)"
|
||||||
|
|
||||||
if [[ "$TIMEOUTBIN" == "" ]]; then
|
if [[ "$TIMEOUTBIN" == "" ]]; then
|
||||||
TIMEOUTBIN="$(which gtimeout)"
|
TIMEOUTBIN="$(which gtimeout)"
|
||||||
if [[ "$TIMEOUTBIN" == "" ]]; then
|
if [[ "$TIMEOUTBIN" == "" ]]; then
|
||||||
echo "neither timeout nor gtimeout are present. install coreutils with {apt-get,yum,brew} install coreutils"
|
echo "neither timeout nor gtimeout are present. install coreutils with {apt-get,yum,brew} install coreutils" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -49,6 +74,31 @@ if [[ "$TIMEOUTOUTPUT" =~ BusyBox ]]; then
|
|||||||
TIMEOUTBIN="$TIMEOUTBIN -t"
|
TIMEOUTBIN="$TIMEOUTBIN -t"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
DIRNAMEPATH=$(dirname "$0")
|
||||||
|
|
||||||
|
if [[ -z $OPENSSLBIN ]]; then
|
||||||
|
readlink_result=$("$READLINKBIN" -f "$0")
|
||||||
|
if [[ -z $readlink_result ]]; then
|
||||||
|
echo "$READLINKBIN -f $0 failed, aborting." 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
REALPATH=$(dirname "$readlink_result")
|
||||||
|
if [[ -z $REALPATH ]]; then
|
||||||
|
echo "dirname $REALPATH failed, aborting." 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
OPENSSLBIN="${REALPATH}/${opensslbin_name}"
|
||||||
|
fi
|
||||||
|
OPENSSLBINHELP="$($OPENSSLBIN s_client -help 2>&1)"
|
||||||
|
if ! [[ $OPENSSLBINHELP =~ -connect ]]; then
|
||||||
|
echo "$OPENSSLBIN s_client doesn't accept the -connect parameter, which is extremely strange; refusing to proceed." 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# use custom config file to enable GOST ciphers
|
# use custom config file to enable GOST ciphers
|
||||||
if [[ -e $DIRNAMEPATH/openssl.cnf ]]; then
|
if [[ -e $DIRNAMEPATH/openssl.cnf ]]; then
|
||||||
export OPENSSL_CONF="$DIRNAMEPATH/openssl.cnf"
|
export OPENSSL_CONF="$DIRNAMEPATH/openssl.cnf"
|
||||||
|
Loading…
Reference in New Issue
Block a user