Skip to content

Commit

Permalink
add parameters to control the reconnection, also increase it to 2 hou…
Browse files Browse the repository at this point in the history
…rs with a minute interval between attempts.
  • Loading branch information
Julio Gutierrez committed Jul 14, 2021
1 parent d9108bb commit 7d73ca7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ services:
* `NETWORK6` - CIDR IPv6 networks (IE fe00:d34d:b33f::/64), add a route to allows replies once the VPN is up.
* `PORTS` - Semicolon delimited list of ports to whitelist for both UDP and TCP. For example '- PORTS=9091;9095'
* `PORT_RANGE` - Port range to whitelist for both UDP and TCP. For example '- PORT_RANGE=9091 9095'
* `CONNECTION_ATTEMPTS` - Number of attempts when trying to establish a connection. (120 by default)
* `CONNECTION_INTERNAL` - Time in seconds to try to establish a connection between connection attempts. (60 by default)
* `CHECK_CONNECTION_INTERVAL` - Time in seconds to check connection and reconnect if need it. (300 by default) For example '- CHECK_CONNECTION_INTERVAL=600'
* `CHECK_CONNECTION_URL` - URL for checking Internet connection. (www.google.com by default) For example '- CHECK_CONNECTION_URL=www.custom.domain'
* `TZ` - Specify a timezone to use. For example '- TZ=Europe/London'
Expand Down
5 changes: 2 additions & 3 deletions start_vpn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,14 @@ fi
connect() {
echo "[$(date -Iseconds)] Connecting..."
attempt_counter=0
max_attempts=360
until nordvpn connect ${CONNECT}; do
if [ ${attempt_counter} -eq ${max_attempts} ]; then
if [ "${attempt_counter}" -eq "${CONNECTION_ATTEMPTS:-120}" ]; then
echo "[$(date -Iseconds)] Unable to connect."
tail -n 200 /var/log/nordvpn/daemon.log
exit 1
fi
attempt_counter=$((attempt_counter + 1))
sleep 10
sleep "${CONNECTION_INTERNAL:-60}"
done
}
connect
Expand Down

0 comments on commit 7d73ca7

Please sign in to comment.