Further improving socket connect timeout

* Handle case when "timeout" couldn't be found
* Proper error message when timeout requested but isn't available
* Fix errorneous message in help()
This commit is contained in:
Dirk 2019-12-10 13:18:45 +01:00
parent 8e02b4a261
commit 20e77318ca
1 changed files with 14 additions and 10 deletions

View File

@ -10248,9 +10248,18 @@ fd_socket() {
break break
fi fi
done done
# For the following execs: 2>/dev/null would remove a potential error message, but disables debugging # For the following execs: 2>/dev/null would remove a potential error message, but disables debugging.
elif ! $TIMEOUT_CMD $CONNECT_TIMEOUT bash -c "exec 5<>/dev/tcp/$nodeip/$PORT" || \ # First we check whether a socket connect timeout was specified
! exec 5<>/dev/tcp/$nodeip/$PORT; then elif [[ -n "$CONNECT_TIMEOUT" ]]; then
if ! $TIMEOUT_CMD $CONNECT_TIMEOUT bash -c "exec 5<>/dev/tcp/$nodeip/$PORT"; then
((NR_SOCKET_FAIL++))
connectivity_problem $NR_SOCKET_FAIL $MAX_SOCKET_FAIL "TCP connect problem" "repeated TCP connect problems (connect timeout), giving up"
outln
pr_warning "Unable to open a socket to $NODEIP:$PORT. "
return 6
fi
# Now comes the the usual case
elif ! exec 5<>/dev/tcp/$nodeip/$PORT; then
((NR_SOCKET_FAIL++)) ((NR_SOCKET_FAIL++))
connectivity_problem $NR_SOCKET_FAIL $MAX_SOCKET_FAIL "TCP connect problem" "repeated TCP connect problems, giving up" connectivity_problem $NR_SOCKET_FAIL $MAX_SOCKET_FAIL "TCP connect problem" "repeated TCP connect problems, giving up"
outln outln
@ -16848,14 +16857,9 @@ find_openssl_binary() {
TIMEOUT_CMD="timeout" TIMEOUT_CMD="timeout"
fi fi
else else
# FIXME: BSD / no timeout. There's a general error using testssl (. It does an exec which fails:
# bash -c 'exec 5<>/dev/tcp/172.17.0.2/443;
TIMEOUT_CMD="" TIMEOUT_CMD=""
outln outln
prln_warning " Necessary binary \"timeout\" not found." fatal "You specified a connect or openssl timeout but the binary \"timeout\" couldn't be found " $ERR_RESOURCE
ignore_no_or_lame " Continue without timeout? " "yes"
# FIXME: ERR message
[[ $? -ne 0 ]] && exit $ERR_OSSLBIN
fi fi
# FIXME: santity check for OPENSSL_TIMEOUT # FIXME: santity check for OPENSSL_TIMEOUT
# OPENSSL_TIMEOUT="$TIMEOUT_CMD" # OPENSSL_TIMEOUT="$TIMEOUT_CMD"
@ -17027,7 +17031,7 @@ tuning / connect options (most also can be preset via environment variables):
output options (can also be preset via environment variables): output options (can also be preset via environment variables):
--warnings <batch|off|false> "batch" doesn't ask for a confirmation, "off" or "false" skips connection warnings --warnings <batch|off|false> "batch" doesn't ask for a confirmation, "off" or "false" skips connection warnings
--connect-timeout <seconds> useful to avoid hangers. Max <seconds> to wait for the socket to return (60 is default) --connect-timeout <seconds> useful to avoid hangers. Max <seconds> to wait for the TCP socket connect to return
--openssl-timeout <seconds> useful to avoid hangers. <seconds> to wait before openssl connect will be terminated --openssl-timeout <seconds> useful to avoid hangers. <seconds> to wait before openssl connect will be terminated
--quiet don't output the banner. By doing this you acknowledge usage terms normally appearing in the banner --quiet don't output the banner. By doing this you acknowledge usage terms normally appearing in the banner
--wide wide output for tests like RC4, BEAST. PFS also with hexcode, kx, strength, RFC name --wide wide output for tests like RC4, BEAST. PFS also with hexcode, kx, strength, RFC name