Browse Source

Fix keeping the server interface state when stop

The server interface wasn't updated in the database when it got stopped.
Which led to 'is_running' was always set to true, if the server has been
started once.

Also fixed a copy-paste issue, which didn't affect the code
pull/15/head
Simon Lerpard 5 years ago
parent
commit
256d7b7901
  1. 12
      wg_dashboard_backend/routers/v1/server.py

12
wg_dashboard_backend/routers/v1/server.py

@ -73,12 +73,14 @@ def add_interface(
@router.post("/stop", response_model=schemas.WGServer)
def start_server(
form_data: schemas.WGServer
def stop_server(
server: schemas.WGServer,
sess: Session = Depends(middleware.get_db)
):
script.wireguard.stop_interface(form_data)
form_data.is_running = script.wireguard.is_running(form_data)
return form_data
script.wireguard.stop_interface(server)
server.is_running = script.wireguard.is_running(server)
server.sync(sess)
return server
@router.post("/start", response_model=schemas.WGServer)

Loading…
Cancel
Save