helps to manage wg connections in a client/server scenario
Find a file
Andrea Zucchelli bce55b225f feat: containers and celery worker
Squashed commit of the following:

commit f3c87deb32
Author: Andrea Zucchelli <zukka77@gmail.com>
Date:   Sun Oct 13 23:47:36 2024 +0200

    chore: refresh button

commit e7c831e0c2
Author: Andrea Zucchelli <zukka77@gmail.com>
Date:   Sun Oct 13 23:37:56 2024 +0200

    feat: wrapping up containers

commit e571b00c3d
Author: Andrea Zucchelli <zukka77@gmail.com>
Date:   Sun Oct 13 21:27:52 2024 +0200

    fix: sort out sub

commit 4a75d4561b
Author: Andrea Zucchelli <zukka77@gmail.com>
Date:   Sun Oct 13 21:24:56 2024 +0200

    fix: sort out sub

commit 3c1030a2fe
Author: Andrea Zucchelli <zukka77@gmail.com>
Date:   Sun Oct 13 20:29:29 2024 +0200

    chore: optimize image build

commit f63d1b185b
Author: Andrea Zucchelli <zukka77@gmail.com>
Date:   Sun Oct 13 20:28:11 2024 +0200

    chore: optimize image build

commit 0d9a175438
Author: Andrea Zucchelli <zukka77@gmail.com>
Date:   Sun Oct 13 20:26:16 2024 +0200

    chore: optimize image build

commit bb510718d2
Author: Andrea Zucchelli <zukka77@gmail.com>
Date:   Sun Oct 13 20:08:22 2024 +0200

    fix: toggle_connection

commit b48a12c1f3
Author: Andrea Zucchelli <zukka77@gmail.com>
Date:   Sun Oct 13 20:02:30 2024 +0200

    fix: toggle_connection

commit 343c36002b
Author: Andrea Zucchelli <zukka77@gmail.com>
Date:   Sun Oct 13 19:27:14 2024 +0200

    fix: serialization

commit 880909912c
Author: Andrea Zucchelli <zukka77@gmail.com>
Date:   Sun Oct 13 19:24:06 2024 +0200

    fix: sync command

commit fbabd0cfca
Author: Andrea Zucchelli <zukka77@gmail.com>
Date:   Sun Oct 13 19:13:10 2024 +0200

    fix: import Peer

commit 444f612452
Author: Andrea Zucchelli <zukka77@gmail.com>
Date:   Sun Oct 13 19:09:28 2024 +0200

    chore: use celery

commit 2f96991294
Author: Andrea Zucchelli <zukka77@gmail.com>
Date:   Sun Oct 13 19:02:40 2024 +0200

    fix: make gunicorn listen on 0.0.0.0

commit 313f23e23c
Author: Andrea Zucchelli <zukka77@gmail.com>
Date:   Sun Oct 13 18:59:22 2024 +0200

    chore: docker stuff compat

commit c17153112b
Author: Andrea Zucchelli <zukka77@gmail.com>
Date:   Sun Oct 13 18:55:39 2024 +0200

    feat: celery decoupling
2024-10-13 23:49:48 +02:00
static/css Merge remote-tracking branch 'origin/feat/css' 2024-10-07 14:41:34 +02:00
templates feat: containers and celery worker 2024-10-13 23:49:48 +02:00
test feat: test 2024-10-09 18:44:53 +02:00
wg_connection_manager feat: containers and celery worker 2024-10-13 23:49:48 +02:00
wg_connection_manager_worker feat: containers and celery worker 2024-10-13 23:49:48 +02:00
wg_manager feat: containers and celery worker 2024-10-13 23:49:48 +02:00
.env-dist feat: containers and celery worker 2024-10-13 23:49:48 +02:00
.gitignore Merge remote-tracking branch 'origin/feat/css' 2024-10-07 14:41:34 +02:00
compose.yaml feat: containers and celery worker 2024-10-13 23:49:48 +02:00
Containerfile feat: containers and celery worker 2024-10-13 23:49:48 +02:00
Containerfile-worker feat: containers and celery worker 2024-10-13 23:49:48 +02:00
LICENSE first import 2024-10-06 12:56:12 +02:00
manage.py first import 2024-10-06 12:56:12 +02:00
pyproject.toml feat: test wip 2024-10-08 23:37:00 +02:00
README.md feat: containers and celery worker 2024-10-13 23:49:48 +02:00
requirements-test.txt chore: requirements-test.txt 2024-10-09 18:56:11 +02:00
requirements-worker.txt feat: containers and celery worker 2024-10-13 23:49:48 +02:00
requirements.txt feat: containers and celery worker 2024-10-13 23:49:48 +02:00

WG-MANAGER

This simple Django web interface helps to manage wg connections in a client/server scenario. Users are allowed to create, enable and disable wg peers.

Warning
this program is alpha quality, not fully tested and can break your computer :D also it must run with root privileges :(

Quickstart container

The container version is made of 3 containers a valkey/redis container a celery worker backend and the django app as frontend.
The django apps invokes the worker via celery through valkey, the worker executes the privileged operations on the wireguard interfaces, the celery worker container ha NET_ADMIN capability and lives in the host network

there's a sample compose file compose.yaml.

first prepare the environment

in wg_manager dir create your own settings.py:

from .settings_dist import *
# your customization here

or simply make a symbolic link:

ln -s settings_dist.py settings.py

copy .env-dist and create your own .env set the variable WG_INTERFACE according to the name of the wg interface you want to manage

star the service

you can start the service running:

docker compose up

The you can connect to the web interface on http://127.0.0.1:4000 default superuser credentials are:

  • user: admin
  • password: admin

you can import existing wireguard peer by visiting the /sync url http://127.0.0.1:4000/sync

Remember that the db insiede the container get destroyed every time the container get destroyed.
You can mount the db as a volume by adding the db as volume in the wg-manager service:

volumes:
    #...
    - ./db.sqlite3:/app/db.sqlite3
    #...

Quickstart standalone

create a python venv:

python -m venv venv

activate it

. venv/bin/activate

install the requirements

pip install -r requirements.txt

in wg_manager dir create your own settings.py:

from .settings_dist import *
# your customization here

or simply make a symbolic link:

ln -s settings_dist.py settings.py

copy .env-dist and create your own .env set the variable WG_INTERFACE according to the name of the wg interface you want to manage

set USE_CELERY=False in environemnt to use only the django app without the privileged worker

create the sqlite db:

./manage.py migrate

collect static assets:

./manage.py collectstatic

create the superuser:

./manage.py createsuperuser

if you already have connections you can import them in the db with:

./manage.py sync

you can test with the integrated dev server:

./manage.py runserver

and then deploy it using a proper web server like gunicorn:

gunicorn wg_manager.wsgi

with a proper tls enabled reverse proxy before it.