Replies¶
Replies are represented by Reply
objects, which hold the flags,
RCODE, and three sets of returned RRs (answers, authorities and additional).
-
class
Reply
¶ -
flags
¶ The flags returned by the server. These are as follows:
Constant Value Meaning AA 0x0400 Authoritative Answer TC 0x0200 Truncated Response RD 0x0100 Recursion Desired RA 0x0080 Recursion Allowed Z 0x0040 Reserved AD 0x0020 Authentic Data (DNSSEC) CD 0x0010 Checking Disabled (DNSSEC)
-
rcode
¶ The RCODE returned by the server. Possible values are:
Constant Value Meaning NOERROR 0 Successful query FORMERR 1 Format failure SERVFAIL 2 Server failure NXDOMAIN 3 Non-existent domain NOTIMP 4 Not implemented REFUSED 5 Query refursed YXDOMAIN 6 Name exists when it should not YXRRSET 7 RR set exists when it should not NXRRSET 8 RR set that should exist does not NOTAUTH 9 Server not authoritative OR Not authorized NOTZONE 10 Name not contained in zone BADVERS 16 Bad OPT version BADSIG 16 TSIG signature failure BADKEY 17 Key not recognized BADTIME 18 Signature out of time window BADMODE 19 Bad TKEY mode BADNAME 20 Duplicate key name BADALG 21 Algorithm not supported BADTRUNC 22 Bad truncation BADCOOKIE 23 Bad/missing server cookie
A list of
rr.RR
returned by the server in the Authorities section of the reply.
-
RRs¶
RRs are represented by subclasses of rr.RR
; a handful of common RR
types have special subclasses that decode the RDATA field in the DNS reply for
you. If you are using some other type of RR, you can create your own subclass
and register it using rr.RR.register()
, or you can just decode the
data in your own code.
-
class
rr.
RR
(name, rr_type, rr_class, ttl)¶ The base class of all RRs. You won’t get a raw
rr.RR
in a Reply - RRs that we don’t understand are mapped torr.Unknown
.-
name
¶ The associated domain name, in the form given in the DNS packet (a
bytes
).
-
unicode_name
¶ The associated domain name, after IDNA processing (a
str
)
-
rr_type
¶ The RR type (see
query
for a list).
-
rr_class
¶ The RR class (see
query
for a list).
-
ttl
¶ The remaining time to live for this RR, in seconds. Note that this field is only updated
-
register
(rr_type, rr_class, pyclass)¶ Register a subclass of
rr.RR
; when we decode a response from the DNS server, we will create an instance of the specified class to represent RRs of the specified type and class.Parameters: - rr_type (int) – The RR type to map.
- rr_class (int) – The RR class to map, or
ANY
if the mapping should operate for any class. - pyclass – The Python class we should use for RRs of the specified type and class.
-
decode
(name, rr_type, rr_class, ttl, packet, ptr, rdlen)¶ Decode an RR from a DNS packet, returning a new
rr.RR
instance representing it. The implementation inrr.RR
looks up the correct Python class and calls itsdecode()
method; if it doesn’t find a class registered for the RR type with which it’s presented, it will userr.Unknown
.Parameters: - name (bytes) – The domain name.
- rr_type (int) – The RR type.
- rr_class (int) – The RR class.
- ttl (int) – The remaining time to live for this RR.
- packet (bytes) – The entire DNS response packet.
- ptr (int) – The current offset within the DNS packet.
- rdlen (int) – The length of the RR’s data, starting from ptr.
-
-
class
rr.
CNAME
(name, ttl, address)¶ -
cname
¶ The aliased name, in the form given in the DNS packet (a
bytes
).
-
unicode_cname
¶ The aliased name after IDNA processing (a
str
)
-
-
class
rr.
HINFO
(name, ttl, cpu, os)¶ -
cpu
¶ The CPU model (as a string).
-
os
¶ The operating system (as a string).
Note that the RFC does not specify the encoding of either string, so for maximum robustness we decode the data as ISO Latin 1. In most cases we would expect the two fields to be ASCII; if they are not, each code point in the resulting string with have the same value as the byte in the byte string.
-
-
class
rr.
MB
(name, ttl, host)¶ -
host
¶ The host specified in the record.
-
unicode_host
¶ The host name after IDNA processing.
-
-
class
rr.
MF
(name, ttl, host)¶ -
host
¶ The host specified in the record.
-
unicode_host
¶ The host name after IDNA processing.
-
-
class
rr.
MG
(name, ttl, mailbox)¶ -
mailbox
¶ The mailbox specified in the record.
-
unicode_mailbox
¶ The mailbox name after IDNA processing.
-
-
class
rr.
MINFO
(name, ttl, mailbox)¶ -
rmailbox
¶
-
emailbox
¶ The mailboxes specified in the record.
-
unicode_rmailbox
¶
-
unicode_emailbox
¶ The mailbox names after IDNA processing.
-
-
class
rr.
MR
(name, ttl, mailbox)¶ -
mailbox
¶ The mailbox specified in the record.
-
unicode_mailbox
¶ The mailbox name after IDNA processing.
-
-
class
rr.
MX
(name, ttl, preference, exchange)¶ -
preference
¶ The mail exchanger priority from the DNS record.
-
exchange
¶ The mail exchanger hostname as found in the DNS packet.
-
unicode_exchange
¶ The mail exchanger hostname after IDNA processing.
-
-
class
rr.
NS
(name, ttl, host)¶ -
host
¶ The hostname of the nameserver.
-
unicode_host
¶ The hostname of the nameserver after IDNA processing.
-
-
class
rr.
PTR
(name, ttl, dname)¶ -
address
¶ The IPv4 or IPv6 address, decoded from name, or
None
if no address could be decoded.
-
dname
¶ The name pointed to by this record.
-
unicode_host
¶ The name poitned to by this record, after IDNA processing.
-
-
rr.SOA(name, ttl, mname, rname, serial, refresh, retry, expire,
-
minimum)
-
mname
¶ The name of the primary mailserver for the zone.
-
unicode_mname
¶ Same as above, but after IDNA processing.
-
rname
¶ The mailbox name of the person responsible for the zone.
-
unicode_rname
¶ As above, but after IDNA processing.
-
serial
¶ The zone’s serial number; this is used to detect changes to a zone (it must be incremented every time a zone is changed).
-
refresh
¶ The number of seconds for which a secondary nameserver may assume the zone data has not changed - controls how often the secondary checks the zone serial number.
-
retry
¶ The number of seconds a secondary should wait to retry a refresh if the primary nameserver is busy.
-
expire
¶ The number of seconds a secondary nameserver can cache the data before it is no longer authoritative.
-
minimum
¶ The minimum time to live for RRs in the zone.
-
-
class
rr.
TXT
(name, ttl, text)¶ -
text
¶ The stored text. Since no encoding is specified, this is decoded as ISO Latin 1 (since that is the most robust option).
-