Browse Source
Merge pull request #15 from simonlerpard/running_state_bugfixes
Running state bugfixes
Looks OK
pull/17/head
Per-Arne Andersen
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
20 additions and
17 deletions
-
README.md
-
wg_dashboard_backend/routers/v1/server.py
-
wg_dashboard_backend/script/wireguard.py
|
|
@ -33,11 +33,12 @@ The features of wg-manager includes: |
|
|
|
wireguard: |
|
|
|
container_name: wg-manager |
|
|
|
image: perara/wg-manager |
|
|
|
restart: always |
|
|
|
cap_add: |
|
|
|
- NET_ADMIN |
|
|
|
#network_mode: host # Alternatively |
|
|
|
ports: |
|
|
|
- 51800:51900/udp |
|
|
|
- 51800-51900:51800-51900/udp |
|
|
|
- 8888:8888 |
|
|
|
volumes: |
|
|
|
- ./wg-manager:/config |
|
|
@ -63,9 +64,9 @@ When docker container/server has started, go to http://localhost:8888 |
|
|
|
|
|
|
|
# Environment variables |
|
|
|
| Environment | Description | Recommended | |
|
|
|
|------------------|--------------------------------------------------------------------------|-------------| |
|
|
|
|------------------|---------------------------------------------------------------------------|-------------| |
|
|
|
| GUNICORN_CONF | Location of custom gunicorn configuration | default | |
|
|
|
| WORKERS_PER_CORE | How many concurrent workers should there be per available core (Gunicorn | default | |
|
|
|
| WORKERS_PER_CORE | How many concurrent workers should there be per available core (Gunicorn) | default | |
|
|
|
| WEB_CONCURRENCY | The number of worker processes for handling requests. (Gunicorn) | 1 | |
|
|
|
| HOST | 0.0.0.0 or unix:/tmp/gunicorn.sock if reverse proxy. Remember to mount | 0.0.0.0 | |
|
|
|
| PORT | The port to use if running with IP host bind | 80 | |
|
|
|
|
|
@ -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) |
|
|
|
|
|
@ -108,7 +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: |
|
|
|
if output is None or b'Unable to access interface: No such device' in output: |
|
|
|
return False |
|
|
|
except Exception as e: |
|
|
|
if b'No such device' in e.output: |
|
|
|