dns :: resolver :: Resolver :: Class Resolver
[hide private]
[frames] | no frames]

Class Resolver

source code

object --+
         |
        Resolver

DNS stub resolver.

Instance Methods [hide private]
 
__init__(self, filename='/etc/resolv.conf', configure=True)
*filename*, a ``text`` or file object, specifying a file in standard /etc/resolv.conf format.
source code
 
reset(self)
Reset all resolver configuration to the defaults.
source code
 
read_resolv_conf(self, f)
Process *f* as a file in the /etc/resolv.conf format.
source code
 
_determine_split_char(self, entry) source code
 
_config_win32_nameservers(self, nameservers) source code
 
_config_win32_domain(self, domain) source code
 
_config_win32_search(self, search) source code
 
_config_win32_fromkey(self, key, always_try_domain) source code
 
read_registry(self)
Extract resolver configuration from the Windows registry.
source code
 
_win32_is_nic_enabled(self, lm, guid, interface_key) source code
 
_compute_timeout(self, start, lifetime=None) source code
 
query(self, qname, rdtype=1, rdclass=1, tcp=False, source=None, raise_on_no_answer=True, source_port=0, lifetime=None)
Query nameservers to find the answer to the question.
source code
 
use_tsig(self, keyring, keyname=None, algorithm=<DNS name HMAC-MD5.SIG-ALG.REG.INT.>)
Add a TSIG signature to the query.
source code
 
use_edns(self, edns, ednsflags, payload)
Configure EDNS behavior.
source code
 
set_flags(self, flags)
Overrides the default flags with your own.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

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

source code 

*filename*, a ``text`` or file object, specifying a file in standard /etc/resolv.conf format. This parameter is meaningful only when *configure* is true and the platform is POSIX.

*configure*, a ``bool``. If True (the default), the resolver instance is configured in the normal fashion for the operating system the resolver is running on. (I.e. by reading a /etc/resolv.conf file on POSIX systems and from the registry on Windows systems.)

Overrides: object.__init__

read_resolv_conf(self, f)

source code 

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

query(self, qname, rdtype=1, rdclass=1, tcp=False, source=None, raise_on_no_answer=True, source_port=0, lifetime=None)

source code 

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.

*qname*, a ``dns.name.Name`` or ``text``, the query name.

*rdtype*, an ``int`` or ``text``, the query type.

*rdclass*, an ``int`` or ``text``, the query class.

*tcp*, a ``bool``. If ``True``, use TCP to make the query.

*source*, a ``text`` or ``None``. If not ``None``, bind to this IP address when making queries.

*raise_on_no_answer*, a ``bool``. If ``True``, raise ``dns.resolver.NoAnswer`` if there's no answer to the question.

*source_port*, an ``int``, the port from which to send the message.

*lifetime*, a ``float``, how long query should run before timing out.

Raises ``dns.exception.Timeout`` if no answers could be found in the specified lifetime.

Raises ``dns.resolver.NXDOMAIN`` if the query name does not exist.

Raises ``dns.resolver.YXDOMAIN`` if the query name is too long after DNAME substitution.

Raises ``dns.resolver.NoAnswer`` if *raise_on_no_answer* is ``True`` and the query name exists but has no RRset of the desired type and class.

Raises ``dns.resolver.NoNameservers`` if no non-broken nameservers are available to answer the question.

Returns a ``dns.resolver.Answer`` instance.

use_tsig(self, keyring, keyname=None, algorithm=<DNS name HMAC-MD5.SIG-ALG.REG.INT.>)

source code 

Add a TSIG signature to the query.

See the documentation of the Message class for a complete description of the keyring dictionary.

*keyring*, a ``dict``, the TSIG keyring to use. 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.

*keyname*, a ``dns.name.Name`` or ``None``, the name of the TSIG key to use; defaults to ``None``. The key must be defined in the keyring.

*algorithm*, a ``dns.name.Name``, the TSIG algorithm to use.

use_edns(self, edns, ednsflags, payload)

source code 

Configure EDNS behavior.

*edns*, an ``int``, is the EDNS level to use. Specifying ``None``, ``False``, or ``-1`` means "do not use EDNS", and in this case the other parameters are ignored. Specifying ``True`` is equivalent to specifying 0, i.e. "use EDNS0".

*ednsflags*, an ``int``, the EDNS flag values.

*payload*, an ``int``, is the EDNS sender's payload field, which is the maximum size of UDP datagram the sender can handle. I.e. how big a response to this message can be.

set_flags(self, flags)

source code 

Overrides the default flags with your own.

*flags*, an ``int``, the message flags to use.