From a631d0d080f06d6c7f907c67fb489e9a0501c28f Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Thu, 2 Nov 2023 09:57:42 -0400 Subject: [PATCH] removed redundant and obsolete code; fixed quotation marks; added some parentheses to emphasize order of operations --- src/registrar/forms/domain.py | 2 +- src/registrar/models/domain.py | 28 ------------------- src/registrar/models/utility/domain_helper.py | 4 --- .../templates/domain_nameservers.html | 2 +- 4 files changed, 2 insertions(+), 34 deletions(-) diff --git a/src/registrar/forms/domain.py b/src/registrar/forms/domain.py index 992d283a4..6e0c16b58 100644 --- a/src/registrar/forms/domain.py +++ b/src/registrar/forms/domain.py @@ -52,7 +52,7 @@ class DomainNameserverForm(forms.Form): ip_list = self.extract_ip_list(ip) # validate if the form has a server or an ip - if ip and ip_list or server: + if (ip and ip_list) or server: self.validate_nameserver_ip_combo(domain, server, ip_list) return cleaned_data diff --git a/src/registrar/models/domain.py b/src/registrar/models/domain.py index ccb96a7d5..5ca1e18bf 100644 --- a/src/registrar/models/domain.py +++ b/src/registrar/models/domain.py @@ -1232,34 +1232,6 @@ class Domain(TimeStampedModel, DomainHelper): # ForeignKey on DomainInvitation creates an "invitations" member for # all of the invitations that have been sent for this domain - def _validate_host_tuples(self, hosts: list[tuple[str]]): - """ - Helper function. Validate hostnames and IP addresses. - - Raises: - ValueError if hostname or IP address appears invalid or mismatched. - """ - for host in hosts: - hostname = host[0].lower() - addresses: tuple[str] = host[1:] # type: ignore - if not bool(Domain.HOST_REGEX.match(hostname)): - raise ValueError("Invalid hostname: %s." % hostname) - if len(hostname) > Domain.MAX_LENGTH: - raise ValueError("Too long hostname: %s" % hostname) - - is_subordinate = hostname.split(".", 1)[-1] == self.name - if is_subordinate and len(addresses) == 0: - raise ValueError( - "Must supply IP addresses for subordinate host %s" % hostname - ) - if not is_subordinate and len(addresses) > 0: - raise ValueError("Must not supply IP addresses for %s" % hostname) - - for address in addresses: - allow = set(":." + digits) - if any(c not in allow for c in address): - raise ValueError("Invalid IP address: %s." % address) - def _get_or_create_domain(self): """Try to fetch info about this domain. Create it if it does not exist.""" already_tried_to_create = False diff --git a/src/registrar/models/utility/domain_helper.py b/src/registrar/models/utility/domain_helper.py index 1a77e44b1..49badd5d7 100644 --- a/src/registrar/models/utility/domain_helper.py +++ b/src/registrar/models/utility/domain_helper.py @@ -11,10 +11,6 @@ class DomainHelper: # begin or end with a hyphen, followed by a TLD of 2-6 alphabetic characters DOMAIN_REGEX = re.compile(r"^(?!-)[A-Za-z0-9-]{1,63}(?
-

Add an IP address only when your name server's address includes your domain name (e.g., if your domain name is "example.gov" and your name server is "ns1.example.gov," then an IP address is required.) To add multiple IP addresses, separate them with commas.

+

Add an IP address only when your name server's address includes your domain name (e.g., if your domain name is “example.gov” and your name server is “ns1.example.gov,” then an IP address is required.) To add multiple IP addresses, separate them with commas.

This step is uncommon unless you self-host your DNS or use custom addresses for your nameserver.