Package dns :: Module message :: Class Message |
[hide private]
[frames] | no frames]

# Class Message

source code

    object --+
             |
            Message

Known Subclasses:
  - update.Update

A DNS message.

Instance Methods | [hide private]
bool |
__eq__(self, other) Two messages are equal if they have the same content in the header, question, answer, and authority sections. | source code
__init__(self, id=None) x.__init__(...) initializes x; see help(type(x)) for signature | source code
bool |
__ne__(self, other) Are two messages not equal? | source code
__repr__(self) repr(x) | source code
__str__(self) str(x) | source code
dns.rrset.RRset object |
find_rrset(self, section, name, rdclass, rdtype, covers=0, deleting=None, create=False, force_unique=False) Find the RRset with the given attributes in the specified section. | source code
dns.rrset.RRset object or None |
get_rrset(self, section, name, rdclass, rdtype, covers=0, deleting=None, create=False, force_unique=False) Get the RRset with the given attributes in the specified section. | source code
bool |
is_response(self, other) Is other a response to self? | source code
int |
opcode(self) Return the opcode. | source code
int |
rcode(self) Return the rcode. | source code
section_number(self, section) | source code
set_opcode(self, opcode) Set the opcode. | source code
set_rcode(self, rcode) Set the rcode. | source code
string |
to_text(self, origin=None, relativize=True, **kw) Convert the message to text. | source code
string |
to_wire(self, origin=None, max_size=0, **kw) Return a string containing the message in DNS compressed wire format. | source code
use_edns(self, edns=0, ednsflags=0, payload=1280, request_payload=None, options=None) Configure EDNS behavior. | source code
use_tsig(self, keyring, keyname=None, fudge=300, original_id=None, tsig_error=0, other_data=`'````'`, algorithm=<DNS name HMAC-MD5.SIG-ALG.REG.INT.>) When sending, a TSIG signature using the specified keyring and keyname should be added. | source code
want_dnssec(self, wanted=True) Enable or disable 'DNSSEC desired' flag in requests. | source code
Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__setattr__`, `__sizeof__`, `__subclasshook__`

Instance Variables | [hide private]
list of dns.rrset.RRset objects | additional The additional data section.
list of dns.rrset.RRset objects | answer The answer section.
list of dns.rrset.RRset objects | authority The authority section.
int | edns The EDNS level to use.
long | ednsflags The EDNS flags
bool | first Is this message standalone, or the first of a multi message sequence? This variable is used when validating TSIG signatures on messages which are part of a zone transfer.
int | flags The DNS flags of the message.
int | fudge TSIG time fudge; default is 300 seconds.
bool | had_tsig Did the message decoded from wire format have a TSIG signature?
int | id The query id; the default is a randomly chosen id.
dict | index An index of rrsets in the message.
string | keyalgorithm The TSIG algorithm to use; defaults to dns.tsig.default_algorithm.
dns.name.Name object | keyname The TSIG keyname to use.
dict | keyring The TSIG keyring to use.
string | mac The TSIG MAC for this message.
bool | multi Is this message part of a multi-message sequence? The default is false.
list of dns.edns.Option objects | options The EDNS options
dns.name.Name object | origin The origin of the zone in messages which are used for zone transfers or for DNS dynamic updates.
int | original_id TSIG original id; defaults to the message's id
string | other_data TSIG other data.
int | payload The EDNS payload size.
list of dns.rrset.RRset objects | question The question section.
string | request_mac The TSIG MAC of the request message associated with this message; used when validating TSIG signatures.
int | request_payload The associated request's EDNS payload size.
hmac.HMAC object | tsig_ctx The TSIG signature context associated with this message.
int | tsig_error TSIG error code; default is 0.
bool | xfr Is the message being used to contain the results of a DNS zone transfer? The default is False.

Properties | [hide private]
Inherited from `object`: `__class__`

Method Details | [hide private]

### __init__(self, id=None) (Constructor) | source code
x.__init__(...) initializes x; see help(type(x)) for signature Overrides: object.__init__ (inherited documentation)

### __repr__(self) (Representation operator) | source code
repr(x) Overrides: object.__repr__ (inherited documentation)

### __str__(self) (Informal representation operator) | source code
str(x) Overrides: object.__str__ (inherited documentation)

### find_rrset(self, section, name, rdclass, rdtype, covers=0, deleting=None, create=False, force_unique=False) | source code
Find the RRset with the given attributes in the specified section. Parameters: `section` (list of dns.rrset.RRset objects) - the section of the message to look in, e.g. self.answer. `name` (dns.name.Name object) - the name of the RRset `rdclass` (int) - the class of the RRset `rdtype` (int) - the type of the RRset `covers` (int) - the covers value of the RRset `deleting` (int) - the deleting value of the RRset `create` (bool) - If True, create the RRset if it is not found. The created RRset is appended to section. `force_unique` (bool) - If True and create is also True, create a new RRset regardless of whether a matching RRset exists already. Returns: dns.rrset.RRset object Raises: `KeyError` - the RRset was not found and create was False

### get_rrset(self, section, name, rdclass, rdtype, covers=0, deleting=None, create=False, force_unique=False) | source code
Get the RRset with the given attributes in the specified section. If the RRset is not found, None is returned. Parameters: `section` (list of dns.rrset.RRset objects) - the section of the message to look in, e.g. self.answer. `name` (dns.name.Name object) - the name of the RRset `rdclass` (int) - the class of the RRset `rdtype` (int) - the type of the RRset `covers` (int) - the covers value of the RRset `deleting` (int) - the deleting value of the RRset `create` (bool) - If True, create the RRset if it is not found. The created RRset is appended to section. `force_unique` (bool) - If True and create is also True, create a new RRset regardless of whether a matching RRset exists already. Returns: dns.rrset.RRset object or None

### set_opcode(self, opcode) | source code
Set the opcode. Parameters: `opcode` (int) - the opcode

### set_rcode(self, rcode) | source code
Set the rcode. Parameters: `rcode` (int) - the rcode

### to_text(self, origin=None, relativize=True, **kw) | source code
Convert the message to text. The origin, relativize, and any other keyword arguments are passed to the rrset to_wire() method. Returns: string

### to_wire(self, origin=None, max_size=0, **kw) | source code
Return a string containing the message in DNS compressed wire format. Additional keyword arguments are passed to the rrset to_wire() method. Parameters: `origin` (dns.name.Name object) - The origin to be appended to any relative names. `max_size` (int) - The maximum size of the wire format output; default is 0, which means 'the message's request payload, if nonzero, or 65536'. Returns: string Raises: `dns.exception.TooBig` - max_size was exceeded

### use_edns(self, edns=0, ednsflags=0, payload=1280, request_payload=None, options=None) | source code
Configure EDNS behavior. Parameters: `edns` (int or bool or None) - 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` (int) - EDNS flag values. `payload` (int) - The EDNS sender's payload field, which is the maximum size of UDP datagram the sender can handle. `request_payload` (int or None) - The EDNS payload size to use when sending this message. If not specified, defaults to the value of payload. `options` (None or list of dns.edns.Option objects) - The EDNS options See Also: RFC 2671

### use_tsig(self, keyring, keyname=None, fudge=300, original_id=None, tsig_error=0, other_data=`'````'`, algorithm=<DNS name HMAC-MD5.SIG-ALG.REG.INT.>) | source code
When sending, a TSIG signature using the specified keyring and keyname should be added. Parameters: `keyring` (dict) - The TSIG keyring to use; defaults to None. `keyname` (dns.name.Name or string) - The name of the TSIG key to use; defaults to None. The key must be defined in the keyring. 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. `fudge` (int) - TSIG time fudge; default is 300 seconds. `original_id` (int) - TSIG original id; defaults to the message's id `tsig_error` (int) - TSIG error code; default is 0. `other_data` (string) - TSIG other data. `algorithm` - The TSIG algorithm to use; defaults to dns.tsig.default_algorithm

### want_dnssec(self, wanted=True) | source code
Enable or disable 'DNSSEC desired' flag in requests. Parameters: `wanted` (bool) - Is DNSSEC desired? If True, EDNS is enabled if required, and then the DO bit is set. If False, the DO bit is cleared if EDNS is enabled.

Instance Variable Details | [hide private]

### edns The EDNS level to use. The default is -1, no Edns. Type: int

### flags The DNS flags of the message. @see: RFC 1035 for an explanation of these flags. Type: int

### index An index of rrsets in the message. The index key is (section, name, rdclass, rdtype, covers, deleting). Indexing can be disabled by setting the index to None. Type: dict

### keyalgorithm The TSIG algorithm to use; defaults to dns.tsig.default_algorithm. Constants for TSIG algorithms are defined in dns.tsig, and the currently implemented algorithms are HMAC_MD5, HMAC_SHA1, HMAC_SHA224, HMAC_SHA256, HMAC_SHA384, and HMAC_SHA512. Type: string

### keyname The TSIG keyname to use. The default is None. Type: dns.name.Name object

### keyring The TSIG keyring to use. The default is None. Type: dict

### multi Is this message part of a multi-message sequence? The default is false. This variable is used when validating TSIG signatures on messages which are part of a zone transfer. Type: bool

### origin The origin of the zone in messages which are used for zone transfers or for DNS dynamic updates. The default is None. Type: dns.name.Name object

### payload The EDNS payload size. The default is 0. Type: int

### request_mac The TSIG MAC of the request message associated with this message; used when validating TSIG signatures. @see: RFC 2845 for more information on TSIG fields. Type: string

### tsig_ctx The TSIG signature context associated with this message. The default is None. Type: hmac.HMAC object