Go to the latest version of this document.

# ``twisted`.`names`.`hosts`.`Resolver``

class documentation

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

Constructor: `Resolver(file, ttl)`

View In Hierarchy

A resolver that services hosts(5) format files.

Method | `__init__` | Undocumented
Method | `lookupAddress` | Read any IPv4 addresses from `self.file` and return them as `Record_A` instances.
Method | `lookupIPV6Address` | Read any IPv6 addresses from `self.file` and return them as `Record_AAAA` instances.
Instance Variable | `file` | Undocumented
Instance Variable | `ttl` | Undocumented
Method | `_aaaaRecords` | Return a tuple of `dns.RRHeader` instances for all of the IPv6 addresses in the hosts file.
Method | `_aRecords` | Return a tuple of `dns.RRHeader` instances for all of the IPv4 addresses in the hosts file.
Method | `_respond` | Generate a response for the given name containing the given result records, or a failure if there are no result records.

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 | `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 | `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 | `lookupZone` | Perform an AXFR record lookup.
Method | `query` | Dispatch `query` to the method which can handle its type.
Instance Variable | `typeToMethod` | Undocumented
Method | `_cbRecords` | Undocumented
Method | `_lookup` | 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 __init__(self, file=b'/etc/hosts', ttl=60 * 60): (source)
overrides `twisted.names.common.ResolverBase.__init__`

Undocumented

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

Read any IPv4 addresses from `self.file` and return them as `Record_A` instances.

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

Read any IPv6 addresses from `self.file` and return them as `Record_AAAA` instances.

file = (source)

Undocumented

ttl = (source)

Undocumented

def _aaaaRecords(self, name): (source)

Return a tuple of `dns.RRHeader` instances for all of the IPv6 addresses in the hosts file.

def _aRecords(self, name): (source)

Return a tuple of `dns.RRHeader` instances for all of the IPv4 addresses in the hosts file.

def _respond(self, name, records): (source)

Generate a response for the given name containing the given result records, or a failure if there are no result records.

Parameters
name:`str` | The DNS name the response is for.
records | A tuple of `dns.RRHeader` instances giving the results that will go into the response.

Returns
A `Deferred` which will fire with a three-tuple of result records, authority records, and additional records, or which will fail with `dns.DomainError` if there are no result records.