From 2fc672690fc70d25f38f1cab07ed4480239877a4 Mon Sep 17 00:00:00 2001 From: Sebastian Lohff Date: Wed, 5 Apr 2017 02:45:04 +0200 Subject: [PATCH] Disallow same nameserver with multiple glues --- domains/forms.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/domains/forms.py b/domains/forms.py index dd3cc9d..87c3731 100644 --- a/domains/forms.py +++ b/domains/forms.py @@ -121,6 +121,16 @@ class NameserverForm(MntFormMixin, WhoisObjectFormMixin, forms.ModelForm): if not found: raise forms.ValidationError("You have glue IPs set, but this domain is not under a domain you control.") + if ipv4 or ipv6: + try: + ns = Nameserver.objects.get(Q(name=name) & (Q(glueIPv4__isnull=False) | Q(glueIPv6__isnull=False))) + if self._create or ns.pk != self.instance.pk: + nsMnts = ", ".join(n.handle for n in ns.mnt_by.all()) + + raise forms.ValidationError("Only one nameserver for this domain can have glue records and one already exists (maintained by %s)" % nsMnts) + except Nameserver.DoesNotExist: + pass + failedMnts = set() for ns in Nameserver.objects.filter(name=name, mnt_by__in=mntBy): if self._create or self.instance.pk != ns.pk: