Browse Source

* Removed warning on missing devices as this is a is_running check. No device appears when device is NOT running.

* Check if interface runs before checking stats.
pull/29/head
Per-Arne Andersen 5 years ago
parent
commit
66617b7698
  1. 4
      wg_dashboard_backend/routers/v1/server.py
  2. 5
      wg_dashboard_backend/script/wireguard.py

4
wg_dashboard_backend/routers/v1/server.py

@ -122,7 +122,11 @@ def delete_server(
@router.post("/stats", dependencies=[Depends(middleware.auth)])
def stats_server(server: schemas.WGServer):
if script.wireguard.is_running(server):
stats = script.wireguard.get_stats(server)
else:
stats = []
return JSONResponse(content=stats)

5
wg_dashboard_backend/script/wireguard.py

@ -108,10 +108,7 @@ def restart_interface(server: schemas.WGServer):
def is_running(server: schemas.WGServer):
try:
output = _run_wg(server, ["show", server.interface])
if output is None or b'Unable to access interface: No such device' in output:
_LOGGER.warning("Unable to access interface: No such device. (%s)"
"This may indicate that there is a bug somewhere, "
"or that you have manually deleted parts of the database", server.interface)
if output is None:
return False
except Exception as e:
if b'No such device' in e.output:

Loading…
Cancel
Save