[wireguard] add unique constrain for keys in pool
This commit is contained in:
parent
858aabb5ba
commit
a0fbe2d6ed
2 changed files with 24 additions and 0 deletions
17
uncloud_net/migrations/0006_auto_20201224_1626.py
Normal file
17
uncloud_net/migrations/0006_auto_20201224_1626.py
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
# Generated by Django 3.1 on 2020-12-24 16:26
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('uncloud_net', '0005_auto_20201220_1837'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddConstraint(
|
||||||
|
model_name='wireguardvpn',
|
||||||
|
constraint=models.UniqueConstraint(fields=('vpnpool', 'wireguard_public_key'), name='wg_key_unique_per_pool'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -84,6 +84,13 @@ class WireGuardVPN(models.Model):
|
||||||
|
|
||||||
wireguard_public_key = models.CharField(max_length=48, unique=True)
|
wireguard_public_key = models.CharField(max_length=48, unique=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
constraints = [
|
||||||
|
models.UniqueConstraint(fields=['vpnpool', 'wireguard_public_key'],
|
||||||
|
name='wg_key_unique_per_pool')
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def network_mask(self):
|
def network_mask(self):
|
||||||
return self.vpnpool.subnetwork_mask
|
return self.vpnpool.subnetwork_mask
|
||||||
|
|
Loading…
Reference in a new issue