use requests for offline test
This commit is contained in:
parent
f76b3807b9
commit
82e8db22f6
@ -1,13 +1,17 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import configparser
|
import configparser
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import requests
|
||||||
import re
|
import re
|
||||||
import io
|
import io
|
||||||
|
|
||||||
def offline():
|
def offline():
|
||||||
expr = re.compile("ips:[^()]+handshake")
|
try:
|
||||||
proc = subprocess.run(["wg", "show", "vpn"], capture_output=True, encoding="utf-8")
|
requests.head("https://1.1.1.1", timeout=1)
|
||||||
return len(expr.findall(proc.stdout)) == 0
|
except Exception:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
def rotate_conf():
|
def rotate_conf():
|
||||||
iface = None
|
iface = None
|
||||||
|
Loading…
Reference in New Issue
Block a user