Package DNS :: Module resolver :: Class Resolver
[show private | hide private]
[frames | no frames]

Class Resolver

object --+
         |
        Resolver


DNS stub resolver
Method Summary
  __init__(self, filename, configure)
Initialize a resolver instance.
a new object with type S, a subtype of T __new__(S, ...)
DNS.resolver.Answer instance query(self, qname, rdtype, rdclass, tcp)
Query nameservers to find the answer to the question.
  read_registry(self)
Extract resolver configuration from the Windows registry.
  read_resolv_conf(self, f)
Process f as a file in the /etc/resolv.conf format.
  reset(self)
Reset all resolver configuration to the defaults.
  use_edns(self, edns, ednsflags, payload)
Configure EDNS.
  use_tsig(self, keyring, keyname)
Add a TSIG signature to the query.
  _config_win32_domain(self, domain)
Configure a Domain registry entry.
  _config_win32_fromkey(self, key)
Extract DNS info from a registry key.
  _config_win32_nameservers(self, nameservers, split_char)
Configure a NameServer registry entry.
  _config_win32_search(self, search)
Configure a Search registry entry.

Instance Variable Summary
DNS.name.Name object domain - The domain of this host
int edns - The EDNS level to use.
int ednsflags - The EDNS flags
DNS.name.Name object keyname - The TSIG keyname to use.
dict keyring - The TSIG keyring to use.
float lifetime - The total number of seconds to spend trying to get an answer to the question.
list of strings nameservers - A list of nameservers to query.
int payload - The EDNS payload size.
int port - The port to which to send queries.
list of DNS.name.Name objects search - The search list.
float timeout - The number of seconds to wait for a response from a server, before timing out.

Method Details

__init__(self, filename='/etc/resolv.conf', configure=True)
(Constructor)

Initialize a resolver instance.
Parameters:
filename - The filename of a configuration file in standard /etc/resolv.conf format. This parameter is meaningful only when configure is true and the platform is POSIX.
           (type=string or file object)
configure - If True (the default), the resolver instance is configured in the normal fashion for the operating system the resolver is running on. (I.e. a /etc/resolv.conf file on POSIX systems and from the registry on Windows systems.)
           (type=bool)

__new__(S, ...)

Returns:
a new object with type S, a subtype of T

query(self, qname, rdtype=1, rdclass=1, tcp=False)

Query nameservers to find the answer to the question.

The qname, rdtype, and rdclass parameters may be objects of the appropriate type, or strings that can be converted into objects of the appropriate type. E.g. For rdtype the integer 2 and the the string 'NS' both mean to query for records with DNS rdata type NS.
Parameters:
qname - the query name
           (type=DNS.name.Name object or string)
rdtype - the query type
           (type=int or string)
rdclass - the query class
           (type=int or string)
tcp - use TCP to make the query (default is False).
           (type=bool)
Returns:
DNS.resolver.Answer instance
Raises:
Timeout - no answers could be found in the specified lifetime
NXDOMAIN - the query name does not exist
NoAnswer - the response did not contain an answer
NoNameservers - no non-broken nameservers are available to answer the question.

read_registry(self)

Extract resolver configuration from the Windows registry.

read_resolv_conf(self, f)

Process f as a file in the /etc/resolv.conf format. If f is a string, it is used as the name of the file to open; otherwise it is treated as the file itself.

reset(self)

Reset all resolver configuration to the defaults.

use_edns(self, edns, ednsflags, payload)

Configure EDNS.
Parameters:
edns - The EDNS level to use. The default is -1, no EDNS.
           (type=int)
ednsflags - The EDNS flags
           (type=int)
payload - The EDNS payload size. The default is 0.
           (type=int)

use_tsig(self, keyring, keyname=None)

Add a TSIG signature to the query.
Parameters:
keyring - The TSIG keyring to use; defaults to None.
           (type=dict)
keyname - The name of the TSIG key to use; defaults to None. The key must be defined in the keyring. If a keyring is specified but a keyname is not, then the key used will be the first key in the keyring. Note that the order of keys in a dictionary is not defined, so applications should supply a keyname when a keyring is used, unless they know the keyring contains only one key.

_config_win32_domain(self, domain)

Configure a Domain registry entry.

_config_win32_fromkey(self, key)

Extract DNS info from a registry key.

_config_win32_nameservers(self, nameservers, split_char=',')

Configure a NameServer registry entry.

_config_win32_search(self, search)

Configure a Search registry entry.

Instance Variable Details

domain

The domain of this host
Type:
DNS.name.Name object

edns

The EDNS level to use. The default is -1, no EDNS.
Type:
int

ednsflags

The EDNS flags
Type:
int

keyname

The TSIG keyname to use. The default is None.
Type:
DNS.name.Name object

keyring

The TSIG keyring to use. The default is None.
Type:
dict

lifetime

The total number of seconds to spend trying to get an answer to the question. If the lifetime expires, a Timeout exception will occur.
Type:
float

nameservers

A list of nameservers to query. Each nameserver is a string which contains the IP address of a nameserver.
Type:
list of strings

payload

The EDNS payload size. The default is 0.
Type:
int

port

The port to which to send queries. The default is 53.
Type:
int

search

The search list. If the query name is a relative name, the resolver will construct an absolute query name by appending the search names one by one to the query name.
Type:
list of DNS.name.Name objects

timeout

The number of seconds to wait for a response from a server, before timing out.
Type:
float

Generated by Epydoc 1.1 on Sat Jun 21 20:52:31 2003 http://epydoc.sf.net