nadzoring.dns_lookup.types module

Type definitions for the DNS lookup module.

All public TypedDict classes and type aliases used across nadzoring.dns_lookup are defined here so that consumers can import types from a single stable location.

Usage example:

from nadzoring.dns_lookup.types import DNSResult, RecordType
from nadzoring.dns_lookup.errors import DNSResolveError

result: DNSResult = {
    "domain": "example.com",
    "record_type": "A",
    "records": ["93.184.216.34"],
    "ttl": 3600,
    "error": None,
    "response_time": 45.67,
}
class nadzoring.dns_lookup.types.BenchmarkResult[source]

Bases: TypedDict

DNS benchmark statistics for a single nameserver.

Variables:
  • server (str) – IP address of the tested DNS server.

  • avg_response_time (float) – Average response time in milliseconds.

  • min_response_time (float) – Fastest observed response time in milliseconds.

  • max_response_time (float) – Slowest observed response time in milliseconds.

  • success_rate (float) – Percentage of successful queries (0.0-100.0).

  • total_queries (int) – Total number of queries attempted.

  • failed_queries (int) – Number of queries that failed or timed out.

  • responses (list[float]) – Individual response times for successful queries.

avg_response_time: float
failed_queries: int
max_response_time: float
min_response_time: float
responses: list[float]
server: str
success_rate: float
total_queries: int
class nadzoring.dns_lookup.types.DNSResult[source]

Bases: TypedDict

DNS resolution result for a single query.

All fields are optional to accommodate partial results from failed queries. The error field uses a Literal type for type-safe error handling.

Variables:
  • domain (str) – The domain name that was queried.

  • record_type (str) – The type of DNS record that was requested.

  • records (list[str]) – List of resolved record strings. Format varies by type: - A / AAAA: IP address strings - MX: "priority mailserver" strings - TXT: Concatenated text chunks - SOA: Space-joined SOA fields - Others: str() with trailing dot stripped

  • ttl (int | None) – Time To Live in seconds, or None when not requested or unavailable.

  • error (Literal['Domain does not exist', 'No records of requested type', 'Query timeout', 'Operation exceeded lifetime timeout', 'Resolver error'] | None) – Human-readable error message if resolution failed; None on success. Error strings are defined in DNSResolveError.

  • response_time (float | None) – Query round-trip time in milliseconds (2 d.p.), or None on timeout.

domain: str
error: Literal['Domain does not exist', 'No records of requested type', 'Query timeout', 'Operation exceeded lifetime timeout', 'Resolver error'] | None
record_type: str
records: list[str]
response_time: float | None
ttl: int | None
class nadzoring.dns_lookup.types.PoisoningCheckResult[source]

Bases: TypedDict

DNS cache poisoning detection result.

Comprehensive analysis comparing responses from multiple resolvers against a trusted control server to detect poisoning, censorship, or manipulation.

Variables:
  • domain (str) – The domain name tested for poisoning.

  • record_type (str) – DNS record type queried.

  • control_server (str) – IP address of the trusted control resolver.

  • control_name (str) – Provider name of the control server.

  • control_country (str) – Country code of the control server.

  • control_result (nadzoring.dns_lookup.types.DNSResult) – DNS resolution result from the control resolver.

  • control_analysis (dict[str, Any]) – IP pattern analysis of control server records.

  • control_owner (str) – Inferred owner of control server IPs.

  • additional_records (dict[str, nadzoring.dns_lookup.types.DNSResult] | None) – Optional extra record types from the control.

  • test_results (dict[str, nadzoring.dns_lookup.types.DNSResult]) – Dict mapping test resolver IPs to their DNS results.

  • test_servers_count (int) – Number of test servers queried.

  • inconsistencies (list[dict[str, Any]]) – Detected discrepancies between resolvers.

  • poisoned (bool) – True when poisoning indicators exceed the threshold.

  • poisoning_level (str) – Severity string — NONE / LOW / MEDIUM / HIGH / CRITICAL / SUSPICIOUS.

  • confidence (float) – Confidence score from 0.0 to 100.0.

  • mismatches (int) – Count of record mismatches across test servers.

  • cdn_variations (int) – Count of CDN-related IP variations.

  • cdn_detected (bool) – Whether CDN usage was identified.

  • cdn_owner (str) – Name of the detected CDN provider.

  • cdn_percentage (float) – Percentage of IPs belonging to the CDN.

  • severity (dict[str, int]) – Dict mapping severity labels to inconsistency counts.

  • unique_ips_seen (int) – Distinct IP count across all test results.

  • ip_diversity (int) – IPs not present in the control result.

  • control_ip_count (int) – IPs returned by the control server.

  • consensus_top (list[dict[str, Any]]) – Top-3 most common IPs with count, percentage, owner.

  • consensus_rate (float) – Percentage of servers returning the most common IP.

  • geo_diversity (int) – Unique country count among test servers.

  • anycast_likely (bool) – True when anycast routing is probable.

  • cdn_likely (bool) – True when CDN usage is probable.

  • poisoning_likely (bool) – True when deliberate poisoning pattern found.

additional_records: dict[str, DNSResult] | None
anycast_likely: bool
cdn_detected: bool
cdn_likely: bool
cdn_owner: str
cdn_percentage: float
cdn_variations: int
confidence: float
consensus_rate: float
consensus_top: list[dict[str, Any]]
control_analysis: dict[str, Any]
control_country: str
control_ip_count: int
control_name: str
control_owner: str
control_result: DNSResult
control_server: str
domain: str
geo_diversity: int
inconsistencies: list[dict[str, Any]]
ip_diversity: int
mismatches: int
poisoned: bool
poisoning_level: str
poisoning_likely: bool
record_type: str
severity: dict[str, int]
test_results: dict[str, DNSResult]
test_servers_count: int
unique_ips_seen: int
nadzoring.dns_lookup.types.RECORD_TYPES: list[str] = ['A', 'AAAA', 'CNAME', 'MX', 'NS', 'TXT', 'PTR', 'SOA', 'DNSKEY']

List of all supported DNS record type strings.

This list excludes "ALL" (a CLI convenience token) and includes only concrete record types that can be queried directly.

type nadzoring.dns_lookup.types.RecordType = Literal['A', 'AAAA', 'CNAME', 'MX', 'NS', 'TXT', 'PTR', 'SOA', 'DNSKEY']

Supported DNS record types for queries and validation.

Values:
  • A: IPv4 address record

  • AAAA: IPv6 address record

  • CNAME: Canonical name (alias)

  • MX: Mail exchange record

  • NS: Nameserver record

  • TXT: Text record (including SPF, DKIM, DMARC)

  • PTR: Pointer record (reverse DNS)

  • SOA: Start of authority record

  • DNSKEY: DNSSEC key record

class nadzoring.dns_lookup.types.ReverseDNSResult[source]

Bases: TypedDict

Reverse DNS lookup result for an IP address.

Variables:
  • ip_address (str) – The original IP address that was queried.

  • hostname (str | None) – Resolved hostname with trailing dot stripped, or None when the lookup failed.

  • error (Literal['No PTR record', 'No reverse DNS', 'Query timeout', 'Invalid IP address', 'Resolver error'] | None) – Error message if resolution failed; None on success. Error strings are defined in DNSReverseError.

  • response_time (float | None) – Query round-trip time in milliseconds (2 d.p.), or None when the query timed out.

error: Literal['No PTR record', 'No reverse DNS', 'Query timeout', 'Invalid IP address', 'Resolver error'] | None
hostname: str | None
ip_address: str
response_time: float | None