From 1767215a4fee920413103597235b7a49bc9af069 Mon Sep 17 00:00:00 2001 From: "black.box (Unzoner) team@belodetek.io" Date: Sun, 3 Dec 2023 11:22:09 -0800 Subject: [PATCH] check client vpn end of loop cycle --- unzoner/Dockerfile.template | 4 +++- unzoner/src/main.py | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/unzoner/Dockerfile.template b/unzoner/Dockerfile.template index 3c56624..a195e74 100644 --- a/unzoner/Dockerfile.template +++ b/unzoner/Dockerfile.template @@ -73,8 +73,10 @@ RUN if [ "$BUILD_OPENSSL" = '1' ]; then \ # https://stackoverflow.com/a/39006247/1559300 RUN if [ "$BUILD_OPENVPN" = '1' ]; then \ - set -x; wget --retry-on-host-error --retry-connrefused --waitretry=2 -q \ + set -x; (wget --retry-on-host-error --retry-connrefused --waitretry=2 -q \ https://swupdate.openvpn.org/community/releases/openvpn-$BUILD_OPENVPN_VERSION.tar.gz \ + || curl --fail --retry 3 https://swupdate.openvpn.org/community/releases/openvpn-$BUILD_OPENVPN_VERSION.tar.gz \ + -o openvpn-$BUILD_OPENVPN_VERSION.tar.gz) \ && tar -xvf openvpn-$BUILD_OPENVPN_VERSION.tar.gz && cd openvpn-$BUILD_OPENVPN_VERSION \ && if [ "$BUILD_OPENSSL" = '1' ]; then CFLAGS='-I/usr/local/ssl/include -Wl,-rpath=/usr/local/ssl/lib -Wl,-rpath=/usr/local/ssl/lib64 -L/usr/local/ssl/lib -L/usr/local/ssl/lib64' ./configure; else ./configure; fi \ && make -j $(nproc) && make check && make install \ diff --git a/unzoner/src/main.py b/unzoner/src/main.py index e2351e9..973da10 100755 --- a/unzoner/src/main.py +++ b/unzoner/src/main.py @@ -189,7 +189,7 @@ def main(): with s_stderrq[idx].mutex: s_stderrq[idx].queue.clear() - if i % LOOP_CYCLE == 0: + if i % LOOP_CYCLE == 0: # at the end of the cycle if DEVICE_TYPE == 3 and connected: # test if double-vpn is up try: shell_check_output_cmd('ip link | grep {}'.format(TUN_IFACE)) @@ -416,7 +416,7 @@ def main(): if DEBUG: print_exc() if connected and not connecting: - if i % LOOP_CYCLE == 0: + if i % LOOP_CYCLE == 0: # at the end of the cycle # run speedtest try: if not c_stimer and dequeue_speedtest(): @@ -455,7 +455,8 @@ def main(): c_iotl )) - if i % POLL_FREQ == 0: # every x cycles per loop + if i % LOOP_CYCLE == 0: # at the end of the cycle + if not connected and connecting: # if client-vpn still connecting, kill and restart try: shell_check_output_cmd('ip link | grep {}'.format(TUN_IFACE)) geo_result = get_geo_location() @@ -469,7 +470,6 @@ def main(): c_proc.terminate() c_pid = None - if i % LOOP_CYCLE == 0: try: log_client_stats(status=connected, country=c_country) except: