mirror of
https://github.com/eduardogsilva/wireguard_webadmin.git
synced 2026-11-22 04:43:18 +01:00
Add distributed cluster mode and sync peer network routes on reload
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user