Skip to content

Commit

Permalink
fix while loop
Browse files Browse the repository at this point in the history
  • Loading branch information
aliel committed Nov 9, 2023
1 parent b2471a7 commit 6d640c4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/aleph/sdk/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ async def get_ns_servers(self, hostname: Hostname):
dns_servers = settings.DNS_RESOLVERS
fqdn = hostname

stop = False
while stop is False:
while True:
"""**Detect and get authoritative NS server of subdomains if delegated**"""
try:
entries = await self.resolver.query(fqdn, "NS")
Expand All @@ -57,15 +56,18 @@ async def get_ns_servers(self, hostname: Hostname):
servers += await self.get_ipv4_addresses(entry.host)

dns_servers = servers
stop = True
break
except aiodns.error.DNSError:
sub_domains = fqdn.split(".")
if len(sub_domains) > 2:
fqdn = Hostname(".".join(sub_domains[1:]))
continue

if len(sub_domains) == 2:
stop = True
break
except Exception as err:
logger.debug(f"Unexpected {err=}, {type(err)=}")
break

return dns_servers

Expand Down

0 comments on commit 6d640c4

Please sign in to comment.