dnspython  1.16.0
About: dnspython is a DNS toolkit (for Python 2.x) that supports almost all record types.
  Fossies Dox: dnspython-1.16.0.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

dns.resolver.Resolver Class Reference
Inheritance diagram for dns.resolver.Resolver:
[legend]
Collaboration diagram for dns.resolver.Resolver:
[legend]

Public Member Functions

def __init__ (self, filename='/etc/resolv.conf', configure=True)
 
def reset (self)
 
def read_resolv_conf (self, f)
 
def read_registry (self)
 
def query (self, qname, rdtype=dns.rdatatype.A, rdclass=dns.rdataclass.IN, tcp=False, source=None, raise_on_no_answer=True, source_port=0, lifetime=None)
 
def use_tsig (self, keyring, keyname=None, algorithm=dns.tsig.default_algorithm)
 
def use_edns (self, edns, ednsflags, payload)
 
def set_flags (self, flags)
 

Public Attributes

 domain
 
 nameservers
 
 nameserver_ports
 
 port
 
 search
 
 timeout
 
 lifetime
 
 keyring
 
 keyname
 
 keyalgorithm
 
 edns
 
 ednsflags
 
 payload
 
 cache
 
 flags
 
 retry_servfail
 
 rotate
 

Private Member Functions

def _determine_split_char (self, entry)
 
def _config_win32_nameservers (self, nameservers)
 
def _config_win32_domain (self, domain)
 
def _config_win32_search (self, search)
 
def _config_win32_fromkey (self, key, always_try_domain)
 
def _win32_is_nic_enabled (self, lm, guid, interface_key)
 
def _compute_timeout (self, start, lifetime=None)
 

Detailed Description

DNS stub resolver.

Definition at line 507 of file resolver.py.

Constructor & Destructor Documentation

◆ __init__()

def dns.resolver.Resolver.__init__ (   self,
  filename = '/etc/resolv.conf',
  configure = True 
)
*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.)

Definition at line 510 of file resolver.py.

Member Function Documentation

◆ _compute_timeout()

def dns.resolver.Resolver._compute_timeout (   self,
  start,
  lifetime = None 
)
private

◆ _config_win32_domain()

def dns.resolver.Resolver._config_win32_domain (   self,
  domain 
)
private

◆ _config_win32_fromkey()

def dns.resolver.Resolver._config_win32_fromkey (   self,
  key,
  always_try_domain 
)
private

◆ _config_win32_nameservers()

def dns.resolver.Resolver._config_win32_nameservers (   self,
  nameservers 
)
private

◆ _config_win32_search()

def dns.resolver.Resolver._config_win32_search (   self,
  search 
)
private

◆ _determine_split_char()

def dns.resolver.Resolver._determine_split_char (   self,
  entry 
)
private

◆ _win32_is_nic_enabled()

def dns.resolver.Resolver._win32_is_nic_enabled (   self,
  lm,
  guid,
  interface_key 
)
private

Definition at line 730 of file resolver.py.

Referenced by dns.resolver.Resolver.read_registry().

◆ query()

def dns.resolver.Resolver.query (   self,
  qname,
  rdtype = dns.rdatatype.A,
  rdclass = dns.rdataclass.IN,
  tcp = False,
  source = None,
  raise_on_no_answer = True,
  source_port = 0,
  lifetime = None 
)
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.

Definition at line 802 of file resolver.py.

References dns.resolver.Resolver._compute_timeout(), dns.resolver.Resolver.cache, dns.rdtypes.CH.A.A.domain, dns.resolver.Resolver.domain, dns.message.Message.edns, dns.resolver.Resolver.edns, dns.message.Message.ednsflags, dns.resolver.Resolver.ednsflags, dns.rdtypes.ANY.CAA.CAA.flags, dns.rdtypes.ANY.CSYNC.CSYNC.flags, dns.rdtypes.ANY.NSEC3PARAM.NSEC3PARAM.flags, dns.rdtypes.IN.NAPTR.NAPTR.flags, dns.rdtypes.ANY.NSEC3.NSEC3.flags, dns.renderer.Renderer.flags, dns.message.Message.flags, dns.rdtypes.dnskeybase.DNSKEYBase.flags, dns.resolver.Resolver.flags, dns.rdataclass.from_text(), dns.rdatatype.from_text(), dns.name.from_text(), dns.hash.get(), dns.rdataclass.is_metaclass(), dns.rdatatype.is_metatype(), dns.message.Message.keyalgorithm, dns.resolver.Resolver.keyalgorithm, dns.message.Message.keyname, dns.resolver.Resolver.keyname, dns.message.Message.keyring, dns.resolver.Resolver.keyring, dns.message.make_query(), dns.resolver.Resolver.nameserver_ports, dns.resolver.Resolver.nameservers, dns.message.Message.payload, dns.resolver.Resolver.payload, dns.rdtypes.IN.SRV.SRV.port, dns.resolver.Resolver.port, dns.resolver.Resolver.retry_servfail, dns.resolver.Resolver.rotate, dns.resolver.Resolver.search, dns.query.tcp(), dns.rcode.to_text(), and dns.query.udp().

◆ read_registry()

def dns.resolver.Resolver.read_registry (   self)
Extract resolver configuration from the Windows registry.

Definition at line 684 of file resolver.py.

References dns.resolver.Resolver._config_win32_fromkey(), and dns.resolver.Resolver._win32_is_nic_enabled().

◆ read_resolv_conf()

def dns.resolver.Resolver.read_resolv_conf (   self,
  f 
)
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.

Definition at line 571 of file resolver.py.

References dns.rdtypes.CH.A.A.domain, dns.resolver.Resolver.domain, dns.name.from_text(), dns.resolver.Resolver.nameservers, dns.resolver.Resolver.rotate, and dns.resolver.Resolver.search.

◆ reset()

◆ set_flags()

def dns.resolver.Resolver.set_flags (   self,
  flags 
)

◆ use_edns()

def dns.resolver.Resolver.use_edns (   self,
  edns,
  ednsflags,
  payload 
)
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.

Definition at line 1036 of file resolver.py.

References dns.message.Message.edns, dns.resolver.Resolver.edns, dns.message.Message.ednsflags, dns.resolver.Resolver.ednsflags, dns.message.Message.payload, and dns.resolver.Resolver.payload.

◆ use_tsig()

def dns.resolver.Resolver.use_tsig (   self,
  keyring,
  keyname = None,
  algorithm = dns.tsig.default_algorithm 
)
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.

Definition at line 1009 of file resolver.py.

References dns.message.Message.keyalgorithm, dns.resolver.Resolver.keyalgorithm, dns.message.Message.keyname, dns.resolver.Resolver.keyname, dns.message.Message.keyring, and dns.resolver.Resolver.keyring.

Member Data Documentation

◆ cache

dns.resolver.Resolver.cache

Definition at line 535 of file resolver.py.

Referenced by dns.resolver.Resolver.query(), and dns.resolver.Resolver.reset().

◆ domain

◆ edns

dns.resolver.Resolver.edns

◆ ednsflags

dns.resolver.Resolver.ednsflags

◆ flags

dns.resolver.Resolver.flags

◆ keyalgorithm

dns.resolver.Resolver.keyalgorithm

◆ keyname

dns.resolver.Resolver.keyname

◆ keyring

dns.resolver.Resolver.keyring

◆ lifetime

dns.resolver.Resolver.lifetime

◆ nameserver_ports

dns.resolver.Resolver.nameserver_ports

Definition at line 524 of file resolver.py.

Referenced by dns.resolver.Resolver.query(), and dns.resolver.Resolver.reset().

◆ nameservers

◆ payload

dns.resolver.Resolver.payload

◆ port

dns.resolver.Resolver.port

Definition at line 525 of file resolver.py.

Referenced by dns.resolver.Resolver.query(), and dns.resolver.Resolver.reset().

◆ retry_servfail

dns.resolver.Resolver.retry_servfail

Definition at line 537 of file resolver.py.

Referenced by dns.resolver.Resolver.query(), and dns.resolver.Resolver.reset().

◆ rotate

dns.resolver.Resolver.rotate

◆ search

◆ timeout

dns.resolver.Resolver.timeout

The documentation for this class was generated from the following file: