Browse Source

Check that entries for reverse DNS belong to the subnet

Baptiste Jonglez 11 years ago
parent
commit
48c04daf52
1 changed files with 6 additions and 0 deletions
  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)