Skip to content

Commit

Permalink
* Custom Domain, raise exception at the end of checks
Browse files Browse the repository at this point in the history
  • Loading branch information
aliel authored and MHHukiewitz committed Jan 30, 2024
1 parent 89f470c commit 7d38872
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions src/aleph/sdk/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,10 @@ async def check_domain(
Returns:
A dictionary containing the status of the domain configuration.
"""
status = {"cname": False, "owner_proof": False}
status = {}

dns_rules = self.get_required_dns_rules(hostname, target, owner)

resolver = await self.get_resolver_for(hostname)
for dns_rule in dns_rules:
status[dns_rule.name] = False

Expand All @@ -199,26 +199,25 @@ async def check_domain(
record_value = dns_rule.dns["value"]

try:
resolver = await self.get_resolver_for(hostname)
entries = await resolver.query(record_name, record_type.upper())
except aiodns.error.DNSError:
# Continue checks
entries = None

if entries and record_type == "txt":
for entry in entries:
if hasattr(entry, "text") and entry.text == record_value:
break
else:
return dns_rule.raise_error(status)
elif (
entries is None
or not hasattr(entries, record_type)
or getattr(entries, record_type) != record_value
):
return dns_rule.raise_error(status)

status[dns_rule.name] = True
if entries:
if record_type == "txt":
for entry in entries:
if hasattr(entry, "text") and entry.text == record_value:
status[dns_rule.name] = True
break
elif (
hasattr(entries, record_type)
and getattr(entries, record_type) == record_value
):
status[dns_rule.name] = True

if all(status.values()) is False:
dns_rule.raise_error(status)

return status

Expand Down

0 comments on commit 7d38872

Please sign in to comment.