nadzoring.network_base.whois_lookup module

WHOIS information lookup for domains and IP addresses.

nadzoring.network_base.whois_lookup._format_whois_value(value: object) → str[source]

Convert python-whois values into display-friendly strings.

nadzoring.network_base.whois_lookup._is_ip(target: str) → bool[source]

Return True if target is a valid IP address.

nadzoring.network_base.whois_lookup._parse_whois_output(raw: str) → dict[str, str | None][source]

Parse raw WHOIS text into a structured dictionary.

Extracts known fields from the WHOIS output by matching line prefixes against a predefined field mapping. Only the first occurrence of each field is captured.

Parameters:

raw – Raw text output from the whois command.

Returns:

Dictionary mapping field names to extracted values.

nadzoring.network_base.whois_lookup._run_whois_command(target: str) → str | None[source]

Execute the system whois command for the given target.

Parameters:

target – Domain or IP address to query.

Returns:

Raw WHOIS output string, or None if the command fails.

Raises:

None - all exceptions are caught and logged. –

nadzoring.network_base.whois_lookup.whois_domain_lookup(domain: str) → list[dict[str, str]][source]

Perform a structured WHOIS lookup for a domain using python-whois.

Parameters:

domain – Domain name to look up.

Returns:

List of field/value dictionaries formatted for CLI output handling.

nadzoring.network_base.whois_lookup.whois_lookup(target: str) → dict[str, str | None][source]

Perform a WHOIS lookup for a domain or IP address.

Uses the system whois command to retrieve ownership and registration information, then parses the output into a structured dictionary.

The returned dictionary’s "error" key, if present, contains one of the literals defined in nadzoring.network_base.errors.WHOISError.

Parameters:

target – Domain name or IP address to look up.

Returns:

Dictionary with parsed WHOIS fields. Contains an ‘error’ key if the lookup failed (e.g., whois is not installed).