Go to the latest version of this document.
search in docstrings

Search bar offers the following options:

- Term presence. The below example searches for documents that must contain “foo”, might contain “bar” and must not contain “baz”: `+foo bar -baz`
- Wildcards. The below example searches for documents with words beginning with “foo”: `foo*`
- Search in specific fields. The following search matches all objects in "twisted.mail" that matches “search”: `+qname:twisted.mail.* +search`

  Possible fields: 'name', 'qname' (fully qualified name), 'docstring', and 'kind'. Last two fields are only applicable if "search in docstrings" is enabled.

- Fuzzy matches. The following search matches all documents that have a word within 1 edit distance of “foo”: `foo~1`

Results provided by Lunr.js

# ``twisted`.`names`.`client`.`Resolver``

class documentation

`class Resolver(common.ResolverBase): (source)`

View In Hierarchy

Method | `__getstate__` | Undocumented
Method | `__init__` | Construct a resolver which will query domain name servers listed in the `resolv.conf(5)`-format file given by `resolv` as well as those in the given `servers` list. Servers are queried in a round-robin fashion...
Method | `__setstate__` | Undocumented
Method | `connectionLost` | Called by associated `dns.DNSProtocol` instances when they disconnect.
Method | `connectionMade` | Called by associated `dns.DNSProtocol` instances when they connect.
Method | `filterAnswers` | Extract results from the given message.
Method | `lookupZone` | Perform an AXFR record lookup.
Method | `maybeParseConfig` | Undocumented
Method | `messageReceived` | Undocumented
Method | `parseConfig` | Undocumented
Method | `pickServer` | Return the address of a nameserver.
Method | `queryTCP` | Make a number of DNS queries via TCP.
Method | `queryUDP` | Make a number of DNS queries via UDP.
Class Variable | `index` | Undocumented
Instance Variable | `connections` | Undocumented
Instance Variable | `dynServers` | Undocumented
Instance Variable | `factory` | Undocumented
Instance Variable | `pending` | Undocumented
Instance Variable | `resolv` | Undocumented
Instance Variable | `servers` | Undocumented
Instance Variable | `timeout` | Undocumented
Method | `_cbLookupZone` | Undocumented
Method | `_connectedProtocol` | Return a new `DNSDatagramProtocol` bound to a randomly selected port number.
Method | `_lookup` | Build a `dns.Query` for the given parameters and dispatch it via UDP.
Method | `_openFile` | Wrapper used for opening files in the class, exists primarily for unit testing purposes.
Method | `_query` | Get a new `DNSDatagramProtocol` instance from `_connectedProtocol`, issue a query to it using `*args`, and arrange for it to be disconnected from its transport after the query completes.
Method | `_reissue` | Undocumented
Method | `_timeoutZone` | Undocumented
Class Variable | `_lastResolvTime` | Undocumented
Class Variable | `_resolvReadInterval` | Undocumented
Instance Variable | `_parseCall` | Undocumented
Instance Variable | `_reactor` | A provider of `IReactorTCP`, `IReactorUDP`, and `IReactorTime` which will be used to set up network resources and track timeouts.

Instance Variable

`_waiting`

A `dict` mapping tuple keys of query name/type/class to Deferreds which will be called back with the result of those queries. This is used to avoid issuing the same query more than once in parallel. This is more efficient on the network and helps avoid a "birthday paradox" attack by keeping the number of outstanding requests for a particular query fixed at one instead of allowing the attacker to raise it to an arbitrary number.

Inherited from `ResolverBase`:

Method | `exceptionForCode` | Convert a response code (one of the possible values of `dns.Message.rCode` to an exception instance representing it.
Method | `getHostByName` | Resolve the domain name `name` into an IP address.
Method | `lookupAddress` | Perform an A record lookup.
Method | `lookupAddress6` | Perform an A6 record lookup.
Method | `lookupAFSDatabase` | Perform an AFSDB record lookup.
Method | `lookupAllRecords` | Perform an ALL_RECORD lookup.
Method | `lookupAuthority` | Perform an SOA record lookup.
Method | `lookupCanonicalName` | Perform a CNAME record lookup.
Method | `lookupHostInfo` | Perform a HINFO record lookup.
Method | `lookupIPV6Address` | Perform an AAAA record lookup.
Method | `lookupMailBox` | Perform an MB record lookup.
Method | `lookupMailboxInfo` | Perform an MINFO record lookup.
Method | `lookupMailExchange` | Perform an MX record lookup.
Method | `lookupMailGroup` | Perform an MG record lookup.
Method | `lookupMailRename` | Perform an MR record lookup.
Method | `lookupNameservers` | Perform an NS record lookup.
Method | `lookupNamingAuthorityPointer` | Perform a NAPTR record lookup.
Method | `lookupNull` | Perform a NULL record lookup.
Method | `lookupPointer` | Perform a PTR record lookup.
Method | `lookupResponsibility` | Perform an RP record lookup.
Method | `lookupSenderPolicy` | Perform a SPF record lookup.
Method | `lookupService` | Perform an SRV record lookup.
Method | `lookupText` | Perform a TXT record lookup.
Method | `lookupWellKnownServices` | Perform a WKS record lookup.
Method | `query` | Dispatch `query` to the method which can handle its type.
Instance Variable | `typeToMethod` | Undocumented
Method | `_cbRecords` | Undocumented
Class Variable | `_errormap` | A `dict` mapping DNS protocol failure response codes to exception classes which will be used to represent those failures.
Class Variable | `_log` | Undocumented

def __getstate__(self): (source)

Undocumented

def __init__(self, resolv=None, servers=None, timeout=(1, 3, 11, 45), reactor=None): (source)
overrides `twisted.names.common.ResolverBase.__init__`

Construct a resolver which will query domain name servers listed in the `resolv.conf(5)`-format file given by `resolv` as well as those in the given `servers` list. Servers are queried in a round-robin fashion. If given, `resolv` is periodically checked for modification and re-parsed if it is noticed to have changed.

Parameters
resolv:`str` | Filename to read and parse as a resolver(5) configuration file.
servers:`list` of `(str, int)` or `None` | If not None, interpreted as a list of (host, port) pairs specifying addresses of domain name servers to attempt to use for this lookup. Host addresses should be in IPv4 dotted-quad form. If specified, overrides `resolv`.
timeout:Sequence of `int` | Default number of seconds after which to reissue the query. When the last timeout expires, the query is considered failed.
reactor | A provider of `IReactorTime`, `IReactorUDP`, and `IReactorTCP` which will be used to establish connections, listen for DNS datagrams, and enforce timeouts. If not provided, the global reactor will be used.
Raises
`ValueError` | Raised if no nameserver addresses can be found.

def __setstate__(self, state): (source)

Undocumented

def connectionLost(self, protocol): (source)

Called by associated `dns.DNSProtocol` instances when they disconnect.

def connectionMade(self, protocol): (source)

Called by associated `dns.DNSProtocol` instances when they connect.

def filterAnswers(self, message): (source)

Extract results from the given message.

If the message was truncated, re-attempt the query over TCP and return a Deferred which will fire with the results of that query.

If the message's result code is not `twisted.names.dns.OK`, return a Failure indicating the type of error which occurred.

Otherwise, return a three-tuple of lists containing the results from the answers section, the authority section, and the additional section.

def lookupZone(self, name, timeout=10): (source)
from `twisted.internet.interfaces.IResolver`
overrides `twisted.names.common.ResolverBase.lookupZone`

Perform an AXFR record lookup.

NB This is quite different from other DNS requests. See http://cr.yp.to/djbdns/axfr-notes.html for more information.

NB Unlike other `lookup*` methods, the timeout here is not a list of ints, it is a single int.

Parameters
name | DNS name to resolve.
timeout | When this timeout expires, the query is considered failed.
Returns
A `Deferred` which fires with a three-tuple of lists of `twisted.names.dns.RRHeader` instances. The first element of the tuple gives answers. The second and third elements are always empty. The `Deferred` may instead fail with one of the exceptions defined in `twisted.names.error` or with `NotImplementedError`.

def maybeParseConfig(self): (source)

Undocumented

def messageReceived(self, message, protocol, address=None): (source)

Undocumented

def parseConfig(self, resolvConf): (source)

Undocumented

def pickServer(self): (source)

Return the address of a nameserver.

TODO: Weight servers for response time so faster ones can be preferred.

def queryTCP(self, queries, timeout=10): (source)

Make a number of DNS queries via TCP.

Parameters
queries:Any non-zero number of `dns.Query` instances | The queries to make.
timeout:`int` | The number of seconds after which to fail.
Returns
`Deferred` | Undocumented

def queryUDP(self, queries, timeout=None): (source)

Make a number of DNS queries via UDP.

Parameters
queries:A `list` of `dns.Query` instances | The queries to make.
timeout:Sequence of `int` | Number of seconds after which to reissue the query. When the last timeout expires, the query is considered failed.
Returns
`Deferred` @raise `twisted.internet.defer.TimeoutError`: When the query times out. | Undocumented

index: `int` = (source)

Undocumented

connections: `list` = (source)

Undocumented

dynServers = (source)

Undocumented

factory = (source)

Undocumented

pending: `list` = (source)

Undocumented

resolv = (source)

Undocumented

servers: `list` = (source)

Undocumented

timeout = (source)

Undocumented

def _cbLookupZone(self, result, connector): (source)

Undocumented

def _connectedProtocol(self, interface=''): (source)

Return a new `DNSDatagramProtocol` bound to a randomly selected port number.

def _lookup(self, name, cls, type, timeout): (source)
overrides `twisted.names.common.ResolverBase._lookup`

Build a `dns.Query` for the given parameters and dispatch it via UDP.

If this query is already outstanding, it will not be re-issued. Instead, when the outstanding query receives a response, that response will be re-used for this query as well.

Parameters
name:`str` | Undocumented
cls:`int` | Undocumented
type:`int` | Undocumented
timeout | Undocumented
Returns
A `Deferred` which fires with a three-tuple giving the answer, authority, and additional sections of the response or with a `Failure` if the response code is anything other than `dns.OK`.

def _openFile(self, path): (source)

Wrapper used for opening files in the class, exists primarily for unit testing purposes.

def _query(self, *args): (source)

Get a new `DNSDatagramProtocol` instance from `_connectedProtocol`, issue a query to it using `*args`, and arrange for it to be disconnected from its transport after the query completes.

Parameters
*args | Positional arguments to be passed to `DNSDatagramProtocol.query`.
Returns
A `Deferred` which will be called back with the result of the query.

def _reissue(self, reason, addressesLeft, addressesUsed, query, timeout): (source)

Undocumented

def _timeoutZone(self, d, controller, connector, seconds): (source)

Undocumented

_lastResolvTime = (source)

Undocumented

_resolvReadInterval: `int` = (source)

Undocumented

_parseCall = (source)

Undocumented

_reactor = (source)

A provider of `IReactorTCP`, `IReactorUDP`, and `IReactorTime` which will be used to set up network resources and track timeouts.

_waiting: `dict` = (source)

A `dict` mapping tuple keys of query name/type/class to Deferreds which will be called back with the result of those queries. This is used to avoid issuing the same query more than once in parallel. This is more efficient on the network and helps avoid a "birthday paradox" attack by keeping the number of outstanding requests for a particular query fixed at one instead of allowing the attacker to raise it to an arbitrary number.