From 82e8db22f6042a432dc5fbf3579db54af476c590 Mon Sep 17 00:00:00 2001 From: Roy Olav Purser Date: Wed, 3 Nov 2021 08:51:41 +0100 Subject: [PATCH] use requests for offline test --- scripts/rotate.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/rotate.py b/scripts/rotate.py index be01781..d72fa03 100755 --- a/scripts/rotate.py +++ b/scripts/rotate.py @@ -1,13 +1,17 @@ #!/usr/bin/env python3 import configparser import subprocess +import requests import re import io def offline(): - expr = re.compile("ips:[^()]+handshake") - proc = subprocess.run(["wg", "show", "vpn"], capture_output=True, encoding="utf-8") - return len(expr.findall(proc.stdout)) == 0 + try: + requests.head("https://1.1.1.1", timeout=1) + except Exception: + return True + else: + return False def rotate_conf(): iface = None