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 Namespace Reference

Classes

class  Answer
 
class  Cache
 
class  LRUCache
 
class  LRUCacheNode
 
class  NoAnswer
 
class  NoMetaqueries
 
class  NoNameservers
 
class  NoRootSOA
 
class  NotAbsolute
 
class  NXDOMAIN
 
class  Resolver
 
class  YXDOMAIN
 

Functions

def get_default_resolver ()
 
def reset_default_resolver ()
 
def query (qname, rdtype=dns.rdatatype.A, rdclass=dns.rdataclass.IN, tcp=False, source=None, raise_on_no_answer=True, source_port=0, lifetime=None)
 
def zone_for_name (name, rdclass=dns.rdataclass.IN, tcp=False, resolver=None)
 
def _getaddrinfo (host=None, service=None, family=socket.AF_UNSPEC, socktype=0, proto=0, flags=0)
 
def _getnameinfo (sockaddr, flags=0)
 
def _getfqdn (name=None)
 
def _gethostbyname (name)
 
def _gethostbyname_ex (name)
 
def _gethostbyaddr (ip)
 
def override_system_resolver (resolver=None)
 
def restore_system_resolver ()
 

Variables

 Timeout = dns.exception.Timeout
 
 default_resolver = None
 
dictionary _protocols_for_socktype
 
 _resolver = None
 
 _original_getaddrinfo = socket.getaddrinfo
 
 _original_getnameinfo = socket.getnameinfo
 
 _original_getfqdn = socket.getfqdn
 
 _original_gethostbyname = socket.gethostbyname
 
 _original_gethostbyname_ex = socket.gethostbyname_ex
 
 _original_gethostbyaddr = socket.gethostbyaddr
 

Function Documentation

◆ _getaddrinfo()

def dns.resolver._getaddrinfo (   host = None,
  service = None,
  family = socket.AF_UNSPEC,
  socktype = 0,
  proto = 0,
  flags = 0 
)
private

◆ _getfqdn()

def dns.resolver._getfqdn (   name = None)
private

Definition at line 1302 of file resolver.py.

References dns.resolver._getaddrinfo(), and dns.resolver._getnameinfo().

◆ _gethostbyaddr()

def dns.resolver._gethostbyaddr (   ip)
private

◆ _gethostbyname()

def dns.resolver._gethostbyname (   name)
private

Definition at line 1311 of file resolver.py.

References dns.resolver._gethostbyname_ex().

◆ _gethostbyname_ex()

def dns.resolver._gethostbyname_ex (   name)
private

Definition at line 1315 of file resolver.py.

References dns.resolver._getaddrinfo().

Referenced by dns.resolver._gethostbyname().

◆ _getnameinfo()

def dns.resolver._getnameinfo (   sockaddr,
  flags = 0 
)
private

◆ get_default_resolver()

def dns.resolver.get_default_resolver ( )
Get the default resolver, initializing it if necessary.

Definition at line 1070 of file resolver.py.

References dns.resolver.reset_default_resolver().

Referenced by dns.resolver.override_system_resolver(), dns.e164.query(), dns.resolver.query(), and dns.resolver.zone_for_name().

◆ override_system_resolver()

def dns.resolver.override_system_resolver (   resolver = None)
Override the system resolver routines in the socket module with
versions which use dnspython's resolver.

This can be useful in testing situations where you want to control
the resolution behavior of python code without having to change
the system's resolver settings (e.g. /etc/resolv.conf).

The resolver to use may be specified; if it's not, the default
resolver will be used.

resolver, a ``dns.resolver.Resolver`` or ``None``, the resolver to use.

Definition at line 1347 of file resolver.py.

References dns.resolver.get_default_resolver().

◆ query()

def dns.resolver.query (   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.

This is a convenience function that uses the default resolver
object to make the query.

See ``dns.resolver.Resolver.query`` for more information on the
parameters.

Definition at line 1088 of file resolver.py.

References dns.resolver.get_default_resolver().

◆ reset_default_resolver()

def dns.resolver.reset_default_resolver ( )
Re-initialize default resolver.

Note that the resolver configuration (i.e. /etc/resolv.conf on UNIX
systems) will be re-read immediately.

Definition at line 1077 of file resolver.py.

Referenced by dns.resolver.get_default_resolver().

◆ restore_system_resolver()

def dns.resolver.restore_system_resolver ( )
Undo the effects of prior override_system_resolver().

Definition at line 1373 of file resolver.py.

◆ zone_for_name()

def dns.resolver.zone_for_name (   name,
  rdclass = dns.rdataclass.IN,
  tcp = False,
  resolver = None 
)
Find the name of the zone which contains the specified name.

*name*, an absolute ``dns.name.Name`` or ``text``, the query name.

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

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

*resolver*, a ``dns.resolver.Resolver`` or ``None``, the resolver to use.
If ``None``, the default resolver is used.

Raises ``dns.resolver.NoRootSOA`` if there is no SOA RR at the DNS
root.  (This is only likely to happen if you're using non-default
root servers in your network and they are misconfigured.)

Returns a ``dns.name.Name``.

Definition at line 1105 of file resolver.py.

References dns.name.from_text(), and dns.resolver.get_default_resolver().

Variable Documentation

◆ _original_getaddrinfo

dns.resolver._original_getaddrinfo = socket.getaddrinfo
private

Definition at line 1154 of file resolver.py.

◆ _original_getfqdn

dns.resolver._original_getfqdn = socket.getfqdn
private

Definition at line 1156 of file resolver.py.

◆ _original_gethostbyaddr

dns.resolver._original_gethostbyaddr = socket.gethostbyaddr
private

Definition at line 1159 of file resolver.py.

◆ _original_gethostbyname

dns.resolver._original_gethostbyname = socket.gethostbyname
private

Definition at line 1157 of file resolver.py.

◆ _original_gethostbyname_ex

dns.resolver._original_gethostbyname_ex = socket.gethostbyname_ex
private

Definition at line 1158 of file resolver.py.

◆ _original_getnameinfo

dns.resolver._original_getnameinfo = socket.getnameinfo
private

Definition at line 1155 of file resolver.py.

◆ _protocols_for_socktype

dictionary dns.resolver._protocols_for_socktype
private
Initial value:
1 = {
2  socket.SOCK_DGRAM: [socket.SOL_UDP],
3  socket.SOCK_STREAM: [socket.SOL_TCP],
4 }

Definition at line 1148 of file resolver.py.

◆ _resolver

dns.resolver._resolver = None
private

Definition at line 1153 of file resolver.py.

◆ default_resolver

dns.resolver.default_resolver = None

Definition at line 1067 of file resolver.py.

◆ Timeout

dns.resolver.Timeout = dns.exception.Timeout

Definition at line 138 of file resolver.py.

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