Package dns :: Module query |
[hide private]
[frames] | no frames]

# Module query

source code

Talk to a DNS server.

Classes | [hide private]
| UnexpectedSource A DNS query response came from an unexpected address or port.
| BadResponse A DNS query response does not respond to the question asked.

Functions | [hide private]
_compute_expiration(timeout) | source code
_poll_for(fd, readable, writable, error, timeout) Poll polling backend. | source code
_select_for(fd, readable, writable, error, timeout) Select polling backend. | source code
_wait_for(fd, readable, writable, error, expiration) | source code
_set_polling_backend(fn) Internal API. | source code
_polling_backend(fd, readable, writable, error, timeout) Select polling backend. | source code
_wait_for_readable(s, expiration) | source code
_wait_for_writable(s, expiration) | source code
_addresses_equal(af, a1, a2) | source code
_destination_and_source(af, where, port, source, source_port) | source code
dns.message.Message object |
udp(q, where, timeout=None, port=53, af=None, source=None, source_port=0, ignore_unexpected=False, one_rr_per_rrset=False) Return the response obtained after sending a query via UDP. | source code
_net_read(sock, count, expiration) Read the specified number of bytes from sock. | source code
_net_write(sock, data, expiration) Write the specified data to the socket. | source code
_connect(s, address) | source code
dns.message.Message object |
tcp(q, where, timeout=None, port=53, af=None, source=None, source_port=0, one_rr_per_rrset=False) Return the response obtained after sending a query via TCP. | source code
generator of dns.message.Message objects. |
xfr(where, zone, rdtype=252, rdclass=1, 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 name HMAC-MD5.SIG-ALG.REG.INT.>) Return a generator for the responses to a zone transfer. | source code

Variables | [hide private]
| __package__ = ``'``dns``'``

Function Details | [hide private]

### _poll_for(fd, readable, writable, error, timeout) | source code
Poll polling backend. Parameters: `fd` (int) - File descriptor `readable` (bool) - Whether to wait for readability `writable` (bool) - Whether to wait for writability `timeout` (float @return True on success, False on timeout) - Deadline timeout (expiration time, in seconds)

### _select_for(fd, readable, writable, error, timeout) | source code
Select polling backend. Parameters: `fd` (int) - File descriptor `readable` (bool) - Whether to wait for readability `writable` (bool) - Whether to wait for writability `timeout` (float @return True on success, False on timeout) - Deadline timeout (expiration time, in seconds)

### _set_polling_backend(fn) | source code
Internal API. Do not use.

### _polling_backend(fd, readable, writable, error, timeout) | source code
Select polling backend. Parameters: `fd` (int) - File descriptor `readable` (bool) - Whether to wait for readability `writable` (bool) - Whether to wait for writability `timeout` (float @return True on success, False on timeout) - Deadline timeout (expiration time, in seconds)

### udp(q, where, timeout=None, port=53, af=None, source=None, source_port=0, ignore_unexpected=False, one_rr_per_rrset=False) | source code
Return the response obtained after sending a query via UDP. Parameters: `q` (dns.message.Message) - the query `where` (string containing an IPv4 or IPv6 address) - where to send the message `timeout` (float) - The number of seconds to wait before the query times out. If None, the default, wait forever. `port` (int) - The port to which to send the message. The default is 53. `af` (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. `source` (string) - source address. The default is the wildcard address. `source_port` (int) - The port from which to send the message. The default is 0. `ignore_unexpected` (bool) - If True, ignore responses from unexpected sources. The default is False. `one_rr_per_rrset` (bool) - Put each RR into its own RRset Returns: dns.message.Message object

### _net_read(sock, count, expiration) | source code
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.

### _net_write(sock, data, expiration) | source code
Write the specified data to the socket. A Timeout exception will be raised if the operation is not completed by the expiration time.

### tcp(q, where, timeout=None, port=53, af=None, source=None, source_port=0, one_rr_per_rrset=False) | source code
Return the response obtained after sending a query via TCP. Parameters: `q` (dns.message.Message object) - the query `where` (string containing an IPv4 or IPv6 address) - where to send the message `timeout` (float) - The number of seconds to wait before the query times out. If None, the default, wait forever. `port` (int) - The port to which to send the message. The default is 53. `af` (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. `source` (string) - source address. The default is the wildcard address. `source_port` (int) - The port from which to send the message. The default is 0. `one_rr_per_rrset` (bool) - Put each RR into its own RRset Returns: dns.message.Message object

### xfr(where, zone, rdtype=252, rdclass=1, 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 name HMAC-MD5.SIG-ALG.REG.INT.>) | source code
Return a generator for the responses to a zone transfer. Parameters: `where` (string containing an IPv4 or IPv6 address) - where to send the message `zone` (dns.name.Name object or string) - The name of the zone to transfer `rdtype` (int or string) - The type of zone transfer. The default is dns.rdatatype.AXFR. `rdclass` (int or string) - The class of the zone transfer. The default is dns.rdataclass.IN. `timeout` (float) - The number of seconds to wait for each response message. If None, the default, wait forever. `port` (int) - The port to which to send the message. The default is 53. `keyring` (dict) - The TSIG keyring to use `keyname` (dns.name.Name object or string) - The name of the TSIG key to use `relativize` (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(). `af` (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. `lifetime` (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` (string) - source address. The default is the wildcard address. `source_port` (int) - The port from which to send the message. The default is 0. `serial` (int) - The SOA serial number to use as the base for an IXFR diff sequence (only meaningful if rdtype == dns.rdatatype.IXFR). `use_udp` (bool) - Use UDP (only meaningful for IXFR) `keyalgorithm` (string) - The TSIG algorithm to use; defaults to dns.tsig.default_algorithm Returns: generator of dns.message.Message objects.