Skip to content

Commit

Permalink
better user error checking
Browse files Browse the repository at this point in the history
  • Loading branch information
FingerlessGlov3s committed Nov 2, 2022
1 parent 5282fa0 commit e85f165
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion PIAWireguard.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,14 @@ def printDebug(text):
opnsenseURL = config['opnsenseURL']

# List current wireguard instances looking for PIA one
r = requests.get(f'{opnsenseURL}/api/wireguard/server/searchServer/', auth=(config['opnsenseKey'], config['opnsenseSecret']), verify=urlVerify)
try:
r = requests.get(f'{opnsenseURL}/api/wireguard/server/searchServer/', auth=(config['opnsenseKey'], config['opnsenseSecret']), verify=urlVerify)
except:
print(f"Failed to connect to {opnsenseURL}, perhaps you've changed the WebUI port please append it (opnsenseURL) EG: https://127.0.0.1:8443")
sys.exit(2)
if r.status_code == 401:
print("searchServer request unauthorized, please check permissions and API keys")
sys.exit(2)
if r.status_code != 200:
print("searchServer request failed non 200 status code - listing wireguard instances")
sys.exit(2)
Expand Down

0 comments on commit e85f165

Please sign in to comment.