Parcourir la source

Check that entries for reverse DNS belong to the subnet

Baptiste Jonglez il y a 11 ans
Parent
commit
48c04daf52
1 fichiers modifiés avec 6 ajouts et 0 suppressions
  1. 6 0
      coin/reverse_dns/models.py

+ 6 - 0
coin/reverse_dns/models.py

@@ -1,4 +1,5 @@
 from django.db import models
+from django.core.exceptions import ValidationError
 from netfields import InetAddressField, NetManager
 from netaddr import IPAddress
 
@@ -24,5 +25,10 @@ class ReverseDNSEntry(models.Model):
 
     objects = NetManager()
 
+    def clean(self):
+        if self.ip:
+            if not self.ip in self.ip_subnet.inet:
+                raise ValidationError('IP address must be included in the IP subnet.')
+
     def __unicode__(self):
         return str(self.ip)