mirror of
https://github.com/eduardogsilva/wireguard_webadmin.git
synced 2026-01-01 14:16:18 +00:00
Add cluster app with initial migrations, models, and settings integration
This commit is contained in:
0
cluster/__init__.py
Normal file
0
cluster/__init__.py
Normal file
3
cluster/admin.py
Normal file
3
cluster/admin.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
6
cluster/apps.py
Normal file
6
cluster/apps.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class ClusterConfig(AppConfig):
|
||||||
|
default_auto_field = 'django.db.models.BigAutoField'
|
||||||
|
name = 'cluster'
|
||||||
69
cluster/migrations/0001_initial.py
Normal file
69
cluster/migrations/0001_initial.py
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
# Generated by Django 5.2.5 on 2025-08-15 00:34
|
||||||
|
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='ClusterSettings',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('name', models.CharField(default='cluster_settings', max_length=16, unique=True)),
|
||||||
|
('enabled', models.BooleanField(default=False)),
|
||||||
|
('primary_enable_wireguard', models.BooleanField(default=True)),
|
||||||
|
('stats_sync_interval', models.IntegerField(default=60)),
|
||||||
|
('stats_cache_interval', models.IntegerField(default=60)),
|
||||||
|
('cluster_mode', models.CharField(default='mirror', max_length=16)),
|
||||||
|
('restart_mode', models.CharField(choices=[('auto', 'Automatically restart/reload'), ('manual', 'Manual')], default='auto', max_length=16)),
|
||||||
|
('worker_display', models.CharField(choices=[('name', 'Name'), ('server_address', 'Server Address'), ('location', 'Location'), ('address_location', 'Address + Location')], default='server_address', max_length=16)),
|
||||||
|
('config_version', models.PositiveIntegerField(default=0)),
|
||||||
|
('updated', models.DateTimeField(auto_now=True)),
|
||||||
|
('created', models.DateTimeField(auto_now_add=True)),
|
||||||
|
('uuid', models.UUIDField(default=uuid.uuid4, editable=False, unique=True)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Worker',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('name', models.CharField(max_length=100, unique=True)),
|
||||||
|
('enabled', models.BooleanField(default=True)),
|
||||||
|
('token', models.UUIDField(default=uuid.uuid4)),
|
||||||
|
('ip_lock', models.BooleanField(default=False)),
|
||||||
|
('ip_address', models.GenericIPAddressField(blank=True, null=True)),
|
||||||
|
('force_reload', models.BooleanField(default=False)),
|
||||||
|
('force_restart', models.BooleanField(default=False)),
|
||||||
|
('country', models.CharField(blank=True, max_length=100, null=True)),
|
||||||
|
('city', models.CharField(blank=True, max_length=100, null=True)),
|
||||||
|
('hostname', models.CharField(blank=True, max_length=100, null=True)),
|
||||||
|
('updated', models.DateTimeField(auto_now=True)),
|
||||||
|
('created', models.DateTimeField(auto_now_add=True)),
|
||||||
|
('uuid', models.UUIDField(default=uuid.uuid4, editable=False, unique=True)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='WorkerStatus',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('last_seen', models.DateTimeField(auto_now=True)),
|
||||||
|
('last_reload', models.DateTimeField(blank=True, null=True)),
|
||||||
|
('last_restart', models.DateTimeField(blank=True, null=True)),
|
||||||
|
('config_version', models.PositiveIntegerField(default=0)),
|
||||||
|
('config_pending', models.BooleanField(default=False)),
|
||||||
|
('updated', models.DateTimeField(auto_now=True)),
|
||||||
|
('created', models.DateTimeField(auto_now_add=True)),
|
||||||
|
('uuid', models.UUIDField(default=uuid.uuid4, editable=False, unique=True)),
|
||||||
|
('worker', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='cluster.worker')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
||||||
0
cluster/migrations/__init__.py
Normal file
0
cluster/migrations/__init__.py
Normal file
60
cluster/models.py
Normal file
60
cluster/models.py
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
import uuid
|
||||||
|
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
|
|
||||||
|
class ClusterSettings(models.Model):
|
||||||
|
name = models.CharField(default='cluster_settings', max_length=16, unique=True)
|
||||||
|
enabled = models.BooleanField(default=False)
|
||||||
|
primary_enable_wireguard = models.BooleanField(default=True)
|
||||||
|
stats_sync_interval = models.IntegerField(default=60)
|
||||||
|
stats_cache_interval = models.IntegerField(default=60)
|
||||||
|
cluster_mode = models.CharField(default='mirror', max_length=16)
|
||||||
|
restart_mode = models.CharField(default='auto', max_length=16, choices=(('auto', 'Automatically restart/reload'), ('manual', 'Manual')))
|
||||||
|
worker_display = models.CharField(
|
||||||
|
default='server_address', max_length=16, choices=(
|
||||||
|
('name', 'Name'), ('server_address', 'Server Address'),
|
||||||
|
('location', 'Location'), ('address_location', 'Address + Location')
|
||||||
|
)
|
||||||
|
)
|
||||||
|
config_version = models.PositiveIntegerField(default=0)
|
||||||
|
|
||||||
|
updated = models.DateTimeField(auto_now=True)
|
||||||
|
created = models.DateTimeField(auto_now_add=True)
|
||||||
|
uuid = models.UUIDField(default=uuid.uuid4, editable=False, unique=True)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.name
|
||||||
|
|
||||||
|
|
||||||
|
class Worker(models.Model):
|
||||||
|
name = models.CharField(max_length=100, unique=True)
|
||||||
|
enabled = models.BooleanField(default=True)
|
||||||
|
token = models.UUIDField(default=uuid.uuid4)
|
||||||
|
ip_lock = models.BooleanField(default=False)
|
||||||
|
ip_address = models.GenericIPAddressField(blank=True, null=True)
|
||||||
|
|
||||||
|
force_reload = models.BooleanField(default=False)
|
||||||
|
force_restart = models.BooleanField(default=False)
|
||||||
|
|
||||||
|
country = models.CharField(max_length=100, blank=True, null=True)
|
||||||
|
city = models.CharField(max_length=100, blank=True, null=True)
|
||||||
|
hostname = models.CharField(max_length=100, blank=True, null=True)
|
||||||
|
|
||||||
|
|
||||||
|
updated = models.DateTimeField(auto_now=True)
|
||||||
|
created = models.DateTimeField(auto_now_add=True)
|
||||||
|
uuid = models.UUIDField(default=uuid.uuid4, editable=False, unique=True)
|
||||||
|
|
||||||
|
|
||||||
|
class WorkerStatus(models.Model):
|
||||||
|
worker = models.OneToOneField(Worker, on_delete=models.CASCADE)
|
||||||
|
last_seen = models.DateTimeField(auto_now=True)
|
||||||
|
last_reload = models.DateTimeField(blank=True, null=True)
|
||||||
|
last_restart = models.DateTimeField(blank=True, null=True)
|
||||||
|
config_version = models.PositiveIntegerField(default=0)
|
||||||
|
config_pending = models.BooleanField(default=False)
|
||||||
|
|
||||||
|
updated = models.DateTimeField(auto_now=True)
|
||||||
|
created = models.DateTimeField(auto_now_add=True)
|
||||||
|
uuid = models.UUIDField(default=uuid.uuid4, editable=False, unique=True)
|
||||||
1
cluster/tests.py
Normal file
1
cluster/tests.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
# Create your tests here.
|
||||||
1
cluster/views.py
Normal file
1
cluster/views.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
# Create your views here.
|
||||||
@@ -45,7 +45,8 @@ INSTALLED_APPS = [
|
|||||||
'wireguard_tools',
|
'wireguard_tools',
|
||||||
'firewall',
|
'firewall',
|
||||||
'dns',
|
'dns',
|
||||||
'vpn_invite'
|
'vpn_invite',
|
||||||
|
'cluster'
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
@@ -148,6 +149,6 @@ STATICFILES_DIRS = [
|
|||||||
DNS_CONFIG_FILE = '/etc/dnsmasq/wireguard_webadmin_dns.conf'
|
DNS_CONFIG_FILE = '/etc/dnsmasq/wireguard_webadmin_dns.conf'
|
||||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||||
|
|
||||||
WIREGUARD_WEBADMIN_VERSION = 9966
|
WIREGUARD_WEBADMIN_VERSION = 9967
|
||||||
|
|
||||||
from wireguard_webadmin.production_settings import *
|
from wireguard_webadmin.production_settings import *
|
||||||
|
|||||||
Reference in New Issue
Block a user