network.dns
Module¶
DNS resolution.
-
wpull.network.dns.
AddressInfo
¶ Socket address.
alias of
_AddressInfo
-
class
wpull.network.dns.
ResolveResult
(address_infos: typing.List, dns_infos: typing.Union=None)[source]¶ Bases:
object
DNS resolution information.
-
addresses
¶ The socket addresses.
-
dns_infos
¶ The DNS resource records.
-
first_ipv4
¶ The first IPv4 address.
-
first_ipv6
¶ The first IPV6 address.
-
-
class
wpull.network.dns.
Resolver
(family: wpull.network.dns.IPFamilyPreference=<IPFamilyPreference.any: 'any'>, timeout: typing.Union=None, bind_address: typing.Union=None, cache: typing.Union=None, rotate: bool=False)[source]¶ Bases:
wpull.application.hook.HookableMixin
Asynchronous resolver with cache and timeout.
Parameters: - family – IPv4 or IPv6 preference.
- timeout – A time in seconds used for timing-out requests. If not specified, this class relies on the underlying libraries.
- bind_address – An IP address to bind DNS requests if possible.
- cache – Cache to store results of any query.
- rotate – If result is cached rotates the results, otherwise, shuffle the results.
-
resolve
(host: str) → wpull.network.dns.ResolveResult[source]¶ Resolve hostname.
Parameters: host – Hostname.
Returns: Resolved IP addresses.
Raises: - DNSNotFound if the hostname could not be resolved or
- NetworkError if there was an error connecting to DNS servers.
Coroutine.
-
static
resolve_dns
(host: str) → str[source]¶ Resolve the hostname to an IP address.
Parameters: host – The hostname. This callback is to override the DNS lookup.
It is useful when the server is no longer available to the public. Typically, large infrastructures will change the DNS settings to make clients no longer hit the front-ends, but rather go towards a static HTTP server with a “We’ve been acqui-hired!” page. In these cases, the original servers may still be online.
Returns: None
to use the original behavior or a string containing an IP address or an alternate hostname.Return type: str, None