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

Classes

class  BadResponse
 
class  TransferError
 
class  UnexpectedSource
 

Functions

def _compute_expiration (timeout)
 
def _poll_for (fd, readable, writable, error, timeout)
 
def _select_for (fd, readable, writable, error, timeout)
 
def _wait_for (fd, readable, writable, error, expiration)
 
def _set_polling_backend (fn)
 
def _wait_for_readable (s, expiration)
 
def _wait_for_writable (s, expiration)
 
def _addresses_equal (af, a1, a2)
 
def _destination_and_source (af, where, port, source, source_port)
 
def send_udp (sock, what, destination, expiration=None)
 
def receive_udp (sock, destination, expiration=None, ignore_unexpected=False, one_rr_per_rrset=False, keyring=None, request_mac=b'', ignore_trailing=False)
 
def udp (q, where, timeout=None, port=53, af=None, source=None, source_port=0, ignore_unexpected=False, one_rr_per_rrset=False, ignore_trailing=False)
 
def _net_read (sock, count, expiration)
 
def _net_write (sock, data, expiration)
 
def send_tcp (sock, what, expiration=None)
 
def receive_tcp (sock, expiration=None, one_rr_per_rrset=False, keyring=None, request_mac=b'', ignore_trailing=False)
 
def _connect (s, address)
 
def tcp (q, where, timeout=None, port=53, af=None, source=None, source_port=0, one_rr_per_rrset=False, ignore_trailing=False)
 
def xfr (where, zone, rdtype=dns.rdatatype.AXFR, rdclass=dns.rdataclass.IN, timeout=None, port=53, keyring=None, keyname=None, relativize=True, af=None, lifetime=None, source=None, source_port=0, serial=0, use_udp=False, keyalgorithm=dns.tsig.default_algorithm)
 

Variables

 select_error = OSError
 
 socket_factory = socket.socket
 
def _polling_backend = _poll_for
 

Function Documentation

◆ _addresses_equal()

def dns.query._addresses_equal (   af,
  a1,
  a2 
)
private

Definition at line 163 of file query.py.

References dns.inet.inet_pton().

Referenced by dns.query.receive_udp().

◆ _compute_expiration()

def dns.query._compute_expiration (   timeout)
private

Definition at line 64 of file query.py.

Referenced by dns.query.tcp(), dns.query.udp(), and dns.query.xfr().

◆ _connect()

def dns.query._connect (   s,
  address 
)
private

Definition at line 428 of file query.py.

Referenced by dns.query.tcp(), and dns.query.xfr().

◆ _destination_and_source()

def dns.query._destination_and_source (   af,
  where,
  port,
  source,
  source_port 
)
private

Definition at line 175 of file query.py.

References dns.inet.af_for_address().

Referenced by dns.query.tcp(), dns.query.udp(), and dns.query.xfr().

◆ _net_read()

def dns.query._net_read (   sock,
  count,
  expiration 
)
private
Read the specified number of bytes from sock.  Keep trying until we
either get the desired amount, or we hit EOF.
A Timeout exception will be raised if the operation is not completed
by the expiration time.

Definition at line 338 of file query.py.

References dns.query._wait_for_readable().

Referenced by dns.query.receive_tcp(), and dns.query.xfr().

◆ _net_write()

def dns.query._net_write (   sock,
  data,
  expiration 
)
private
Write the specified data to the socket.
A Timeout exception will be raised if the operation is not completed
by the expiration time.

Definition at line 355 of file query.py.

References dns.query._wait_for_writable().

Referenced by dns.query.send_tcp(), and dns.query.xfr().

◆ _poll_for()

def dns.query._poll_for (   fd,
  readable,
  writable,
  error,
  timeout 
)
private
Poll polling backend.

Definition at line 75 of file query.py.

References dns._compat.long.

◆ _select_for()

def dns.query._select_for (   fd,
  readable,
  writable,
  error,
  timeout 
)
private
Select polling backend.

Definition at line 97 of file query.py.

◆ _set_polling_backend()

def dns.query._set_polling_backend (   fn)
private

Definition at line 139 of file query.py.

◆ _wait_for()

def dns.query._wait_for (   fd,
  readable,
  writable,
  error,
  expiration 
)
private

Definition at line 117 of file query.py.

References dns.query._polling_backend.

Referenced by dns.query._wait_for_readable(), and dns.query._wait_for_writable().

◆ _wait_for_readable()

def dns.query._wait_for_readable (   s,
  expiration 
)
private

Definition at line 155 of file query.py.

References dns.query._wait_for().

Referenced by dns.query._net_read(), dns.query.receive_udp(), and dns.query.xfr().

◆ _wait_for_writable()

def dns.query._wait_for_writable (   s,
  expiration 
)
private

◆ receive_tcp()

def dns.query.receive_tcp (   sock,
  expiration = None,
  one_rr_per_rrset = False,
  keyring = None,
  request_mac = b'',
  ignore_trailing = False 
)
Read a DNS message from a TCP socket.

*sock*, a ``socket``.

*expiration*, a ``float`` or ``None``, the absolute time at which
a timeout exception should be raised.  If ``None``, no timeout will
occur.

*one_rr_per_rrset*, a ``bool``.  If ``True``, put each RR into its own
RRset.

*keyring*, a ``dict``, the keyring to use for TSIG.

*request_mac*, a ``binary``, the MAC of the request (for TSIG).

*ignore_trailing*, a ``bool``.  If ``True``, ignore trailing
junk at end of the received message.

Raises if the message is malformed, if network errors occur, of if
there is a timeout.

Returns a ``dns.message.Message`` object.

Definition at line 393 of file query.py.

References dns.query._net_read(), and dns.message.from_wire().

Referenced by dns.query.tcp().

◆ receive_udp()

def dns.query.receive_udp (   sock,
  destination,
  expiration = None,
  ignore_unexpected = False,
  one_rr_per_rrset = False,
  keyring = None,
  request_mac = b'',
  ignore_trailing = False 
)
Read a DNS message from a UDP socket.

*sock*, a ``socket``.

*destination*, a destination tuple appropriate for the address family
of the socket, specifying where the associated query was sent.

*expiration*, a ``float`` or ``None``, the absolute time at which
a timeout exception should be raised.  If ``None``, no timeout will
occur.

*ignore_unexpected*, a ``bool``.  If ``True``, ignore responses from
unexpected sources.

*one_rr_per_rrset*, a ``bool``.  If ``True``, put each RR into its own
RRset.

*keyring*, a ``dict``, the keyring to use for TSIG.

*request_mac*, a ``binary``, the MAC of the request (for TSIG).

*ignore_trailing*, a ``bool``.  If ``True``, ignore trailing
junk at end of the received message.

Raises if the message is malformed, if network errors occur, of if
there is a timeout.

Returns a ``dns.message.Message`` object.

Definition at line 223 of file query.py.

References dns.query._addresses_equal(), dns.query._wait_for_readable(), dns.message.from_wire(), and dns.inet.is_multicast().

Referenced by dns.query.udp().

◆ send_tcp()

def dns.query.send_tcp (   sock,
  what,
  expiration = None 
)
Send a DNS message to the specified TCP socket.

*sock*, a ``socket``.

*what*, a ``binary`` or ``dns.message.Message``, the message to send.

*expiration*, a ``float`` or ``None``, the absolute time at which
a timeout exception should be raised.  If ``None``, no timeout will
occur.

Returns an ``(int, float)`` tuple of bytes sent and the sent time.

Definition at line 367 of file query.py.

References dns.query._net_write(), and dns.query._wait_for_writable().

Referenced by dns.query.tcp().

◆ send_udp()

def dns.query.send_udp (   sock,
  what,
  destination,
  expiration = None 
)
Send a DNS message to the specified UDP socket.

*sock*, a ``socket``.

*what*, a ``binary`` or ``dns.message.Message``, the message to send.

*destination*, a destination tuple appropriate for the address family
of the socket, specifying where to send the query.

*expiration*, a ``float`` or ``None``, the absolute time at which
a timeout exception should be raised.  If ``None``, no timeout will
occur.

Returns an ``(int, float)`` tuple of bytes sent and the sent time.

Definition at line 198 of file query.py.

References dns.query._wait_for_writable().

Referenced by dns.query.udp().

◆ tcp()

def dns.query.tcp (   q,
  where,
  timeout = None,
  port = 53,
  af = None,
  source = None,
  source_port = 0,
  one_rr_per_rrset = False,
  ignore_trailing = False 
)
Return the response obtained after sending a query via TCP.

*q*, a ``dns.message.Message``, the query to send

*where*, a ``text`` containing an IPv4 or IPv6 address,  where
to send the message.

*timeout*, a ``float`` or ``None``, the number of seconds to wait before the
query times out.  If ``None``, the default, wait forever.

*port*, an ``int``, the port send the message to.  The default is 53.

*af*, an ``int``, the address family to use.  The default is ``None``,
which causes the address family to use to be inferred from the form of
*where*.  If the inference attempt fails, AF_INET is used.  This
parameter is historical; you need never set it.

*source*, a ``text`` containing an IPv4 or IPv6 address, specifying
the source address.  The default is the wildcard address.

*source_port*, an ``int``, the port from which to send the message.
The default is 0.

*one_rr_per_rrset*, a ``bool``.  If ``True``, put each RR into its own
RRset.

*ignore_trailing*, a ``bool``.  If ``True``, ignore trailing
junk at end of the received message.

Returns a ``dns.message.Message``.

Definition at line 442 of file query.py.

References dns.query._compute_expiration(), dns.query._connect(), dns.query._destination_and_source(), dns.query.receive_tcp(), dns.query.send_tcp(), and dns.query.socket_factory.

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

◆ udp()

def dns.query.udp (   q,
  where,
  timeout = None,
  port = 53,
  af = None,
  source = None,
  source_port = 0,
  ignore_unexpected = False,
  one_rr_per_rrset = False,
  ignore_trailing = False 
)
Return the response obtained after sending a query via UDP.

*q*, a ``dns.message.Message``, the query to send

*where*, a ``text`` containing an IPv4 or IPv6 address,  where
to send the message.

*timeout*, a ``float`` or ``None``, the number of seconds to wait before the
query times out.  If ``None``, the default, wait forever.

*port*, an ``int``, the port send the message to.  The default is 53.

*af*, an ``int``, the address family to use.  The default is ``None``,
which causes the address family to use to be inferred from the form of
*where*.  If the inference attempt fails, AF_INET is used.  This
parameter is historical; you need never set it.

*source*, a ``text`` containing an IPv4 or IPv6 address, specifying
the source address.  The default is the wildcard address.

*source_port*, an ``int``, the port from which to send the message.
The default is 0.

*ignore_unexpected*, a ``bool``.  If ``True``, ignore responses from
unexpected sources.

*one_rr_per_rrset*, a ``bool``.  If ``True``, put each RR into its own
RRset.

*ignore_trailing*, a ``bool``.  If ``True``, ignore trailing
junk at end of the received message.

Returns a ``dns.message.Message``.

Definition at line 274 of file query.py.

References dns.query._compute_expiration(), dns.query._destination_and_source(), dns.query.receive_udp(), dns.query.send_udp(), and dns.query.socket_factory.

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

◆ xfr()

def dns.query.xfr (   where,
  zone,
  rdtype = dns.rdatatype.AXFR,
  rdclass = dns.rdataclass.IN,
  timeout = None,
  port = 53,
  keyring = None,
  keyname = None,
  relativize = True,
  af = None,
  lifetime = None,
  source = None,
  source_port = 0,
  serial = 0,
  use_udp = False,
  keyalgorithm = dns.tsig.default_algorithm 
)
Return a generator for the responses to a zone transfer.

*where*.  If the inference attempt fails, AF_INET is used.  This
parameter is historical; you need never set it.

*zone*, a ``dns.name.Name`` or ``text``, the name of the zone to transfer.

*rdtype*, an ``int`` or ``text``, the type of zone transfer.  The
default is ``dns.rdatatype.AXFR``.  ``dns.rdatatype.IXFR`` can be
used to do an incremental transfer instead.

*rdclass*, an ``int`` or ``text``, the class of the zone transfer.
The default is ``dns.rdataclass.IN``.

*timeout*, a ``float``, the number of seconds to wait for each
response message.  If None, the default, wait forever.

*port*, an ``int``, the port send the message to.  The default is 53.

*keyring*, a ``dict``, the keyring to use for TSIG.

*keyname*, a ``dns.name.Name`` or ``text``, the name of the TSIG
key to use.

*relativize*, a ``bool``.  If ``True``, all names in the zone will be
relativized to the zone origin.  It is essential that the
relativize setting matches the one specified to
``dns.zone.from_xfr()`` if using this generator to make a zone.

*af*, an ``int``, the address family to use.  The default is ``None``,
which causes the address family to use to be inferred from the form of
*where*.  If the inference attempt fails, AF_INET is used.  This
parameter is historical; you need never set it.

*lifetime*, a ``float``, the total number of seconds to spend
doing the transfer.  If ``None``, the default, then there is no
limit on the time the transfer may take.

*source*, a ``text`` containing an IPv4 or IPv6 address, specifying
the source address.  The default is the wildcard address.

*source_port*, an ``int``, the port from which to send the message.
The default is 0.

*serial*, an ``int``, the SOA serial number to use as the base for
an IXFR diff sequence (only meaningful if *rdtype* is
``dns.rdatatype.IXFR``).

*use_udp*, a ``bool``.  If ``True``, use UDP (only meaningful for IXFR).

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

Raises on errors, and so does the generator.

Returns a generator of ``dns.message.Message`` objects.

Definition at line 504 of file query.py.

References dns.query._compute_expiration(), dns.query._connect(), dns.query._destination_and_source(), dns.query._net_read(), dns.query._net_write(), dns.query._wait_for_readable(), dns.query._wait_for_writable(), dns.rrset.from_text(), dns.rdatatype.from_text(), dns.name.from_text(), dns.message.from_wire(), dns.message.make_query(), and dns.query.socket_factory.

Variable Documentation

◆ _polling_backend

def dns.query._polling_backend = _poll_for
private

Definition at line 150 of file query.py.

Referenced by dns.query._wait_for().

◆ select_error

dns.query.select_error = OSError

Definition at line 39 of file query.py.

◆ socket_factory

dns.query.socket_factory = socket.socket

Definition at line 45 of file query.py.

Referenced by dns.query.tcp(), dns.query.udp(), and dns.query.xfr().