| |
- exit(status=None, /)
- Exit the interpreter by raising SystemExit(status).
If the status is omitted or None, it defaults to zero (i.e., success).
If the status is an integer, it will be used as the system exit status.
If it is another kind of object, it will be printed and the system
exit status will be one (i.e., failure).
- get_event_loop()
- Return an asyncio event loop.
When called from a coroutine or a callback (e.g. scheduled with
call_soon or similar API), this function will always return the
running event loop.
If there is no running event loop set, the function will return
the result of `get_event_loop_policy().get_event_loop()` call.
- main() -> int
- Main function to parse arguments and run DNS resolution.
Returns:
Exit code: 0 on success, 1 on usage error, 2 on DNS resolution failure.
- pack(...)
- pack(format, v1, v2, ...) -> bytes
Return a bytes object containing the values v1, v2, ... packed according
to the format string. See help(struct) for more on format strings.
- parse_dns_response(response_data: bytes) -> List[str]
- Parse DNS response to extract IPv4 addresses from A records.
Args:
response_data: Raw DNS response bytes.
Returns:
List of IPv4 addresses as strings.
- async resolve_all(domain_names: List[str], **kwargs) -> List[Tuple[str, List[str]]]
- Resolve all domain names concurrently.
Args:
domain_names: List of domain names.
Returns:
List of tuples containing domain and result.
- async resolve_domain(domain_name: str, dns_server_ip: str = '8.8.8.8', dns_server_port: int = 53) -> Tuple[str, List[str]]
- Resolve a single domain asynchronously.
Args:
domain_name: The domain name to resolve.
dns_server_ip: DNS server IP address.
Returns:
Tuple of domain name and list of IPs or error message.
- async send_dns_tcp_query(domain_name: str, dns_server_ip: str = '8.8.8.8', dns_server_port: int = 53) -> List[str]
- Send a DNS query using TCP.
Args:
domain_name: The domain name to resolve.
dns_server_ip: The DNS server IP address.
Returns:
List of IPv4 addresses.
Raises:
TimeoutError if no response is received.
- async send_dns_udp_query(domain_name: str, dns_server_ip: str = '8.8.8.8', dns_server_port: int = 53, **kwargs) -> List[str]
- Send a DNS query using fully asynchronous UDP sockets.
Args:
domain_name (str): The domain name to resolve.
dns_server_ip (str): The IP address of the DNS server.
dns_server_port (int): The port number of the DNS server (default: 53).
Returns:
List[str]: A list of resolved IPv4 addresses.
Raises:
asyncio.TimeoutError: If no response is received within 2 seconds.
Exception: For socket or protocol errors.
- unpack(format, buffer, /)
- Return a tuple containing values unpacked according to the format string.
The buffer's size in bytes must be calcsize(format).
See help(struct) for more on format strings.
|