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
+11
View File
@@ -1,11 +1,15 @@
import uuid
from django.db import models
from django.db.models import Q
from django.utils.translation import gettext_lazy as _
from wireguard.models import NETMASK_CHOICES
from wireguard.models import Peer, WireGuardInstance
# Interface of a single WireGuard instance (wg0, wg1...). wg+ matches every instance.
INSTANCE_INTERFACE_REGEX = r'^wg[0-9]+$'
class RedirectRule(models.Model):
description = models.CharField(max_length=100, blank=True, null=True)
@@ -69,6 +73,13 @@ class FirewallRule(models.Model):
def __str__(self):
return str(self.uuid)
@classmethod
def with_instance_interface(cls):
"""Rules bound to the interface of a specific instance, not allowed in the distributed cluster mode."""
return cls.objects.filter(
Q(in_interface__regex=INSTANCE_INTERFACE_REGEX) | Q(out_interface__regex=INSTANCE_INTERFACE_REGEX)
)
class FirewallSettings(models.Model):
name = models.CharField(max_length=6, default='global', unique=True)