Finite reconnects from client/server sides

This commit is contained in:
Ivan Ilves 2017-04-02 18:01:29 +02:00
parent 46e7959ffb
commit 1c9117892e
2 changed files with 25 additions and 11 deletions

View File

@ -2,8 +2,6 @@
#
# Execute/teardown on the server side
#
set -e
if [[ ${#} != 2 ]]; then
echo "Usage: ${0} TUNNEL_ID IP_BASE"
exit 1
@ -26,6 +24,18 @@ function teardown() {
}
echo "CONNECTED"
while true; do
sleep 60000 # TODO: Maybe we need some heartbeat here
FAILED_PINGS=0
while [[ ${FAILED_PINGS} -lt 5 ]]; do
ping -c3 -nq ${CLIENT_IP_ADDR} >/dev/null
if [[ ${?} -ne 0 ]]; then
let FAILED_PINGS+=1
logger -i -p warn "xiringuito[${TUNNEL_ID}]: Failed to ping ${CLIENT_IP_ADDR} (${FAILED_PINGS})"
else
FAILED_PINGS=0
fi
sleep 5
done
teardown

View File

@ -50,7 +50,7 @@ fi
declare -r TUNNEL_ID=$(cat ${TUNNEL_ID_FILE})
declare -r REMOTE_PATH="/tmp/xiringuito.${TUNNEL_ID}"
declare -r SSH_OPTS="-oLogLevel=${SSH_LOG_LEVEL:-ERROR} -oConnectTimeout=10"
declare -r SSH_OPTS="-oLogLevel=${SSH_LOG_LEVEL:-ERROR} -oConnectionAttempts=3 -oConnectTimeout=10"
if [[ ${KERNEL} == linux ]]; then
declare -r LOCAL_TUNNEL_ID=${TUNNEL_ID}
@ -120,13 +120,17 @@ if [[ ! ${NO_DNS} && ! -z "${NETWORKS}" ]]; then
fi
set +e
while true; do
if [[ ! ${NO_PING} ]]; then
./scripts/client-ping-server.sh ${TUNNEL_ID} ${IP_BASE}
if [[ ${?} -ne 0 ]]; then
echo "* Failed to ping server-side tunnel endpoint..."
fi
FAILED_PINGS=0
while [[ ${FAILED_PINGS} -lt 5 ]]; do
./scripts/client-ping-server.sh ${TUNNEL_ID} ${IP_BASE}
if [[ ${?} -ne 0 ]]; then
let FAILED_PINGS+=1
echo "* Failed to ping server-side tunnel endpoint... (${FAILED_PINGS})"
else
FAILED_PINGS=0
fi
sleep 5
done
teardown