Add speed profiles to limit the bandwidth of each peer

This commit is contained in:
Eduardo Silva
2026-11-24 17:05:13 -03:00
parent 026c82445b
commit 3f2da7e545
35 changed files with 1538 additions and 25 deletions
+13
View File
@@ -14,6 +14,7 @@ from django.utils.translation import gettext_lazy as _
from cluster.models import ClusterSettings, Worker
from scheduler.models import PeerScheduling
from speed_profiles.models import SpeedProfile
from wireguard.models import NETMASK_CHOICES, Peer, PeerAllowedIP
from wireguard_peer.functions import find_network_in_other_instance
@@ -92,6 +93,18 @@ def normalize_endpoint(value):
return f'{host.lower()}:{int(port)}'
class PeerSpeedProfileForm(PeerModelForm):
speed_profile = forms.ModelChoiceField(
queryset=SpeedProfile.objects.order_by('name'), label=_('Speed profile'), required=False,
empty_label=_('No limit'),
help_text=_('Download and upload limits of this peer. Speed profiles are managed from the peer list.'),
)
class Meta:
model = Peer
fields = ['speed_profile']
class PeerEndpointForm(PeerModelForm):
endpoint = forms.CharField(
label=_('Endpoint'), required=False,