Skip to content

Commit 1922647

Browse files
committed
fix(ovpn): catching output if unable to resolve myip.opendns.com
1 parent d94bd6d commit 1922647

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

‎src/nethsec/ovpn/__init__.py‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,17 @@ def get_public_addresses(u):
6363
for addr in data[0].get('addr_info', []):
6464
if addr.get("local", None):
6565
try:
66-
cmd = f"/usr/bin/dig -b {addr.get('local')} +short +time=1 myip.opendns.com @resolver1.opendns.com".split(" ")
67-
output = subprocess.check_output(cmd, timeout=5)
68-
ret[output.decode().strip()] = 1
66+
res = subprocess.run([
67+
"/usr/bin/dig",
68+
"-b",
69+
addr.get("local"),
70+
"+short",
71+
"+time=1",
72+
"myip.opendns.com",
73+
"@resolver1.opendns.com"
74+
],
75+
capture_output=True, text=True, check=True)
76+
ret[res.stdout.strip()] = 1
6977
except:
7078
pass
7179
return list(ret.keys())

0 commit comments

Comments
 (0)