Add distributed cluster mode and sync peer network routes on reload

This commit is contained in:
Eduardo Silva
2026-11-20 20:42:42 -03:00
parent 5f6e2cd61c
commit 0ee6c2b864
25 changed files with 993 additions and 70 deletions
+10 -1
View File
@@ -3,12 +3,16 @@ import uuid
from django.db import models
from django.utils.translation import gettext_lazy as _
DISTRIBUTED_MODES = ('distributed',)
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)
cluster_mode = models.CharField(default='mirror', max_length=16, choices=(('mirror', 'Mirror'), ))
cluster_mode = models.CharField(
default='mirror', max_length=16, choices=(('mirror', 'Mirror'), ('distributed', 'Distributed'))
)
worker_display = models.CharField(
default='server_address', max_length=16, choices=(
('name', 'Name'), ('server_address', 'Server Address'),
@@ -27,6 +31,11 @@ class ClusterSettings(models.Model):
def cluster_enabled(cls):
return cls.objects.filter(name='cluster_settings', enabled=True).exists()
@classmethod
def is_distributed(cls):
"""Each WireGuard instance runs on a single server. Only applies while the cluster is enabled."""
return cls.objects.filter(name='cluster_settings', enabled=True, cluster_mode__in=DISTRIBUTED_MODES).exists()
class Worker(models.Model):
name = models.CharField(max_length=100, unique=True)