[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
|
|
@ -84,6 +84,13 @@ class WireGuardVPN(models.Model):
|
|||
|
||||
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
|
||||
def network_mask(self):
|
||||
return self.vpnpool.subnetwork_mask
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue