Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

* Custom Domain, raise exception at the end of checks #90

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading