Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mxsasha committed Dec 3, 2024
1 parent d4fa825 commit 3579607
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions checks/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ def http_get_af(
Other (kw)args are passed to requests.get.
"""
if af == socket.AF_INET6:
ips = resolve_aaaa(hostname)
ips, _ = resolve_aaaa(hostname)
else:
ips = resolve_a(hostname)
ips, _ = resolve_a(hostname)
exc = NoIpError(f"Unable to resolve {'AAAA' if af == socket.AF_INET6 else 'A'} record for host '{hostname}'")
for ip in ips:
try:
Expand Down
10 changes: 5 additions & 5 deletions checks/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,29 @@ def from_message(cls, message: Message):
return cls(DNSSECStatus.UNSIGNED)


def resolve_a(label: str, allow_bogus=False) -> Tuple[List[str], DNSSECStatus]:
def resolve_a(label: str, allow_bogus=True) -> Tuple[List[str], DNSSECStatus]:
rrset, dnssec_status = resolve(label, RdataType.A, allow_bogus)
return [rr.address for rr in rrset], dnssec_status


def resolve_aaaa(label: str, allow_bogus=False) -> Tuple[List[str], DNSSECStatus]:
def resolve_aaaa(label: str, allow_bogus=True) -> Tuple[List[str], DNSSECStatus]:
rrset, dnssec_status = resolve(label, RdataType.AAAA, allow_bogus)
return [rr.address for rr in rrset], dnssec_status


def resolve_txt(label: str, allow_bogus=False) -> Tuple[List[str], DNSSECStatus]:
def resolve_txt(label: str, allow_bogus=True) -> Tuple[List[str], DNSSECStatus]:
rrset, dnssec_status = resolve(label, RdataType.TXT, allow_bogus)
return [rr.to_text()[1:-1] for rr in rrset], dnssec_status


def resolve_spf(label: str, allow_bogus=False) -> Tuple[Optional[str], DNSSECStatus]:
def resolve_spf(label: str, allow_bogus=True) -> Tuple[Optional[str], DNSSECStatus]:
strings, dnssec_status = resolve_txt(label, allow_bogus)
spf_records = [s for s in strings if s.lower().startswith("v=spf1")]
result = spf_records[0] if len(spf_records) == 1 else None
return result, dnssec_status


def resolve(label: str, rr_type: RdataType, allow_bogus=False):
def resolve(label: str, rr_type: RdataType, allow_bogus=True):
answer = get_resolver().resolve(dns.name.from_text(label), rr_type)
dnssec_status = DNSSECStatus.from_message(answer.response)
if dnssec_status == DNSSECStatus.BOGUS and not allow_bogus:
Expand Down

0 comments on commit 3579607

Please sign in to comment.