mirror of
https://github.com/eduardogsilva/wireguard_webadmin.git
synced 2026-11-27 07:06:03 +01:00
Add speed profiles to limit the bandwidth of each peer
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user