dns
dns
¶
DNS resolution utilities for BigBrotr.
Provides async hostname resolution for both IPv4 (A record) and IPv6 (AAAA record) addresses. Used by the Monitor service for relay DNS checks and IP geolocation.
Note
Resolution uses the system resolver via socket.gethostbyname and
socket.getaddrinfo, delegated to threads with asyncio.to_thread
to avoid blocking the event loop. Each address family is resolved
independently so that failure of one does not affect the other.
This module provides basic A/AAAA resolution only. For comprehensive DNS record collection (CNAME, NS, PTR, TTL), see the NIP-66 DNS module.
See Also
bigbrotr.nips.nip66.dns.Nip66DnsMetadata:
Full DNS record collection (A, AAAA, CNAME, NS, PTR) using dnspython.
bigbrotr.nips.nip66.geo.Nip66GeoMetadata:
Geolocation lookup that depends on this module for IP resolution.
bigbrotr.nips.nip66.net.Nip66NetMetadata:
Network/ASN lookup that depends on this module for IP resolution.
Classes¶
ResolvedHost
dataclass
¶
Immutable result of hostname resolution containing IPv4 and IPv6 addresses.
See Also
resolve_host: The async function that produces instances of this class.
Functions¶
resolve_host
async
¶
resolve_host(
host: str, *, timeout: float = 5.0
) -> ResolvedHost
Resolve a hostname to IPv4 and IPv6 addresses asynchronously.
Performs independent A and AAAA record lookups using the system resolver
via asyncio.to_thread. Failure of one address family does not affect
the other. Each lookup is bounded by timeout to prevent indefinite
blocking on unresponsive DNS servers.
Parameters:
-
host(str) –Hostname to resolve (e.g.,
"relay.damus.io"). -
timeout(float, default:5.0) –Maximum seconds to wait for each DNS lookup (default 5.0).
Returns:
-
ResolvedHost–ResolvedHost with resolved addresses (
Nonefor failed lookups).
Note
All exceptions from the underlying socket calls are suppressed,
including asyncio.TimeoutError.
A completely unresolvable hostname returns a
ResolvedHost with both fields
set to None and has_ip == False rather than raising.
Examples: