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.message.Message Class Reference
Inheritance diagram for dns.message.Message:
[legend]
Collaboration diagram for dns.message.Message:
[legend]

Public Member Functions

def __init__ (self, id=None)
 
def __repr__ (self)
 
def __str__ (self)
 
def to_text (self, origin=None, relativize=True, **kw)
 
def __eq__ (self, other)
 
def __ne__ (self, other)
 
def is_response (self, other)
 
def section_number (self, section)
 
def section_from_number (self, number)
 
def find_rrset (self, section, name, rdclass, rdtype, covers=dns.rdatatype.NONE, deleting=None, create=False, force_unique=False)
 
def get_rrset (self, section, name, rdclass, rdtype, covers=dns.rdatatype.NONE, deleting=None, create=False, force_unique=False)
 
def to_wire (self, origin=None, max_size=0, **kw)
 
def use_tsig (self, keyring, keyname=None, fudge=300, original_id=None, tsig_error=0, other_data=b'', algorithm=dns.tsig.default_algorithm)
 
def use_edns (self, edns=0, ednsflags=0, payload=1280, request_payload=None, options=None)
 
def want_dnssec (self, wanted=True)
 
def rcode (self)
 
def set_rcode (self, rcode)
 
def opcode (self)
 
def set_opcode (self, opcode)
 

Public Attributes

 id
 
 flags
 
 question
 
 answer
 
 authority
 
 additional
 
 edns
 
 ednsflags
 
 payload
 
 options
 
 request_payload
 
 keyring
 
 keyname
 
 keyalgorithm
 
 request_mac
 
 other_data
 
 tsig_error
 
 fudge
 
 original_id
 
 mac
 
 xfr
 
 origin
 
 tsig_ctx
 
 had_tsig
 
 multi
 
 first
 
 index
 

Detailed Description

A DNS message.

Definition at line 83 of file message.py.

Constructor & Destructor Documentation

◆ __init__()

def dns.message.Message.__init__ (   self,
  id = None 
)

Definition at line 86 of file message.py.

Member Function Documentation

◆ __eq__()

def dns.message.Message.__eq__ (   self,
  other 
)
Two messages are equal if they have the same content in the
header, question, answer, and authority sections.

Returns a ``bool``.

Definition at line 181 of file message.py.

References dns.message.Message.answer, dns.message.Message.authority, dns.message.Message.flags, dns.message.Message.id, and dns.message.Message.question.

Referenced by dns.node.Node.__ne__(), dns.zone.Zone.__ne__(), dns.rdataset.Rdataset.__ne__(), dns.message.Message.__ne__(), and dns.set.Set.__ne__().

◆ __ne__()

def dns.message.Message.__ne__ (   self,
  other 
)

Definition at line 214 of file message.py.

References dns.edns.Option.__eq__(), and dns.message.Message.__eq__().

◆ __repr__()

def dns.message.Message.__repr__ (   self)

Definition at line 118 of file message.py.

References dns.message.Message.id.

◆ __str__()

def dns.message.Message.__str__ (   self)

◆ find_rrset()

def dns.message.Message.find_rrset (   self,
  section,
  name,
  rdclass,
  rdtype,
  covers = dns.rdatatype.NONE,
  deleting = None,
  create = False,
  force_unique = False 
)
Find the RRset with the given attributes in the specified section.

*section*, an ``int`` section number, or one of the section
attributes of this message.  This specifies the
the section of the message to search.  For example::

    my_message.find_rrset(my_message.answer, name, rdclass, rdtype)
    my_message.find_rrset(dns.message.ANSWER, name, rdclass, rdtype)

*name*, a ``dns.name.Name``, the name of the RRset.

*rdclass*, an ``int``, the class of the RRset.

*rdtype*, an ``int``, the type of the RRset.

*covers*, an ``int`` or ``None``, the covers value of the RRset.
The default is ``None``.

*deleting*, an ``int`` or ``None``, the deleting value of the RRset.
The default is ``None``.

*create*, a ``bool``.  If ``True``, create the RRset if it is not found.
The created RRset is appended to *section*.

*force_unique*, a ``bool``.  If ``True`` and *create* is also ``True``,
create a new RRset regardless of whether a matching RRset exists
already.  The default is ``False``.  This is useful when creating
DDNS Update messages, as order matters for them.

Raises ``KeyError`` if the RRset was not found and create was
``False``.

Returns a ``dns.rrset.RRset object``.

Definition at line 287 of file message.py.

References dns.hash.get(), dns.message.Message.index, dns.message.Message.section_from_number(), and dns.message.Message.section_number().

Referenced by dns.update.Update._add_rr(), dns.update.Update.absent(), dns.update.Update.delete(), dns.message.Message.get_rrset(), dns.zone.Zone.get_rrset(), and dns.update.Update.present().

◆ get_rrset()

def dns.message.Message.get_rrset (   self,
  section,
  name,
  rdclass,
  rdtype,
  covers = dns.rdatatype.NONE,
  deleting = None,
  create = False,
  force_unique = False 
)
Get the RRset with the given attributes in the specified section.

If the RRset is not found, None is returned.

*section*, an ``int`` section number, or one of the section
attributes of this message.  This specifies the
the section of the message to search.  For example::

    my_message.get_rrset(my_message.answer, name, rdclass, rdtype)
    my_message.get_rrset(dns.message.ANSWER, name, rdclass, rdtype)

*name*, a ``dns.name.Name``, the name of the RRset.

*rdclass*, an ``int``, the class of the RRset.

*rdtype*, an ``int``, the type of the RRset.

*covers*, an ``int`` or ``None``, the covers value of the RRset.
The default is ``None``.

*deleting*, an ``int`` or ``None``, the deleting value of the RRset.
The default is ``None``.

*create*, a ``bool``.  If ``True``, create the RRset if it is not found.
The created RRset is appended to *section*.

*force_unique*, a ``bool``.  If ``True`` and *create* is also ``True``,
create a new RRset regardless of whether a matching RRset exists
already.  The default is ``False``.  This is useful when creating
DDNS Update messages, as order matters for them.

Returns a ``dns.rrset.RRset object`` or ``None``.

Definition at line 348 of file message.py.

References dns.message.Message.find_rrset().

◆ is_response()

def dns.message.Message.is_response (   self,
  other 
)
Is this message a response to *other*?

Returns a ``bool``.

Definition at line 217 of file message.py.

References dns.message.Message.flags, dns.opcode.from_flags(), dns.rcode.from_flags(), dns.message.Message.id, dns.opcode.is_update(), and dns.message.Message.question.

◆ opcode()

def dns.message.Message.opcode (   self)
Return the opcode.

Returns an ``int``.

Definition at line 569 of file message.py.

References dns.message.Message.flags, and dns.opcode.from_flags().

◆ rcode()

def dns.message.Message.rcode (   self)
Return the rcode.

Returns an ``int``.

Definition at line 549 of file message.py.

References dns.message.Message.ednsflags, dns.message.Message.flags, and dns.rcode.from_flags().

◆ section_from_number()

def dns.message.Message.section_from_number (   self,
  number 
)
Return the "section number" of the specified section for use
in indexing.  The question section is 0, the answer section is 1,
the authority section is 2, and the additional section is 3.

*section* is one of the section attributes of this message.

Raises ``ValueError`` if the section isn't known.

Returns an ``int``.

Definition at line 264 of file message.py.

References dns.message.Message.additional, dns.message.Message.answer, dns.message.Message.authority, and dns.message.Message.question.

Referenced by dns.message.Message.find_rrset().

◆ section_number()

def dns.message.Message.section_number (   self,
  section 
)
Return the "section number" of the specified section for use
in indexing.  The question section is 0, the answer section is 1,
the authority section is 2, and the additional section is 3.

*section* is one of the section attributes of this message.

Raises ``ValueError`` if the section isn't known.

Returns an ``int``.

Definition at line 241 of file message.py.

References dns.message.Message.additional, dns.message.Message.answer, dns.message.Message.authority, and dns.message.Message.question.

Referenced by dns.message.Message.find_rrset().

◆ set_opcode()

def dns.message.Message.set_opcode (   self,
  opcode 
)
Set the opcode.

*opcode*, an ``int``, is the opcode to set.

Definition at line 576 of file message.py.

References dns.message.Message.flags, and dns.opcode.to_flags().

◆ set_rcode()

def dns.message.Message.set_rcode (   self,
  rcode 
)
Set the rcode.

*rcode*, an ``int``, is the rcode to set.

Definition at line 556 of file message.py.

References dns.message.Message.edns, dns.message.Message.ednsflags, dns.message.Message.flags, dns._compat.long, and dns.rcode.to_flags().

◆ to_text()

◆ to_wire()

def dns.message.Message.to_wire (   self,
  origin = None,
  max_size = 0,
**  kw 
)
Return a string containing the message in DNS compressed wire
format.

Additional keyword arguments are passed to the RRset ``to_wire()``
method.

*origin*, a ``dns.name.Name`` or ``None``, the origin to be appended
to any relative names.

*max_size*, an ``int``, the maximum size of the wire format
output; default is 0, which means "the message's request
payload, if nonzero, or 65535".

Raises ``dns.exception.TooBig`` if *max_size* was exceeded.

Returns a ``binary``.

Definition at line 392 of file message.py.

References dns.message.Message.additional, dns.message.Message.answer, dns.message.Message.authority, dns.message.Message.edns, dns.message.Message.ednsflags, dns.message.Message.flags, dns.message.Message.fudge, dns.message.Message.id, dns.message.Message.keyalgorithm, dns.message.Message.keyname, dns.message.Message.keyring, dns.message.Message.mac, dns.message.Message.options, dns.message.Message.original_id, dns.message.Message.other_data, dns.message.Message.payload, dns.message.Message.question, dns.message.Message.request_mac, dns.message.Message.request_payload, and dns.message.Message.tsig_error.

Referenced by dns.rdtypes.nsbase.UncompressedNS.to_digestable(), dns.rdtypes.mxbase.UncompressedMX.to_digestable(), and dns.rdata.Rdata.to_digestable().

◆ use_edns()

def dns.message.Message.use_edns (   self,
  edns = 0,
  ednsflags = 0,
  payload = 1280,
  request_payload = None,
  options = None 
)
Configure EDNS behavior.

*edns*, an ``int``, is 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*, an ``int``, the EDNS flag values.

*payload*, an ``int``, is the EDNS sender's payload field, which is the
maximum size of UDP datagram the sender can handle.  I.e. how big
a response to this message can be.

*request_payload*, an ``int``, is the EDNS payload size to use when
sending this message.  If not specified, defaults to the value of
*payload*.

*options*, a list of ``dns.edns.Option`` objects or ``None``, the EDNS
options.

Definition at line 487 of file message.py.

References dns.message.Message.edns, dns.message.Message.ednsflags, dns._compat.long, dns.message.Message.options, dns.message.Message.payload, and dns.message.Message.request_payload.

Referenced by dns.message.Message.want_dnssec().

◆ use_tsig()

def dns.message.Message.use_tsig (   self,
  keyring,
  keyname = None,
  fudge = 300,
  original_id = None,
  tsig_error = 0,
  other_data = b'',
  algorithm = dns.tsig.default_algorithm 
)
When sending, a TSIG signature using the specified keyring
and keyname should be added.

See the documentation of the Message class for a complete
description of the keyring dictionary.

*keyring*, a ``dict``, the TSIG keyring to use.  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.

*keyname*, a ``dns.name.Name`` or ``None``, the name of the TSIG key
to use; defaults to ``None``. The key must be defined in the keyring.

*fudge*, an ``int``, the TSIG time fudge.

*original_id*, an ``int``, the TSIG original id.  If ``None``,
the message's id is used.

*tsig_error*, an ``int``, the TSIG error code.

*other_data*, a ``binary``, the TSIG other data.

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

Definition at line 440 of file message.py.

References dns.name.from_text(), dns.message.Message.fudge, dns.message.Message.id, dns.message.Message.keyalgorithm, dns.message.Message.keyname, dns.message.Message.keyring, dns.message.Message.original_id, dns.message.Message.other_data, and dns.message.Message.tsig_error.

◆ want_dnssec()

def dns.message.Message.want_dnssec (   self,
  wanted = True 
)
Enable or disable 'DNSSEC desired' flag in requests.

*wanted*, a ``bool``.  If ``True``, then DNSSEC data is
desired in the response, EDNS is enabled if required, and then
the DO bit is set.  If ``False``, the DO bit is cleared if
EDNS is enabled.

Definition at line 533 of file message.py.

References dns.message.Message.edns, dns.message.Message.ednsflags, and dns.message.Message.use_edns().

Member Data Documentation

◆ additional

◆ answer

◆ authority

◆ edns

◆ ednsflags

◆ first

dns.message.Message.first

Definition at line 115 of file message.py.

◆ flags

◆ fudge

dns.message.Message.fudge

Definition at line 107 of file message.py.

Referenced by dns.message.Message.to_wire(), and dns.message.Message.use_tsig().

◆ had_tsig

dns.message.Message.had_tsig

Definition at line 113 of file message.py.

◆ id

◆ index

dns.message.Message.index

Definition at line 116 of file message.py.

Referenced by dns.message.Message.find_rrset().

◆ keyalgorithm

◆ keyname

◆ keyring

◆ mac

dns.message.Message.mac

◆ multi

dns.message.Message.multi

Definition at line 114 of file message.py.

◆ options

dns.message.Message.options

◆ origin

◆ original_id

dns.message.Message.original_id

Definition at line 108 of file message.py.

Referenced by dns.message.Message.to_wire(), and dns.message.Message.use_tsig().

◆ other_data

dns.message.Message.other_data

Definition at line 105 of file message.py.

Referenced by dns.message.Message.to_wire(), and dns.message.Message.use_tsig().

◆ payload

◆ question

◆ request_mac

dns.message.Message.request_mac

Definition at line 104 of file message.py.

Referenced by dns.message.Message.to_wire().

◆ request_payload

dns.message.Message.request_payload

Definition at line 100 of file message.py.

Referenced by dns.message.Message.to_wire(), and dns.message.Message.use_edns().

◆ tsig_ctx

dns.message.Message.tsig_ctx

Definition at line 112 of file message.py.

◆ tsig_error

dns.message.Message.tsig_error

Definition at line 106 of file message.py.

Referenced by dns.message.Message.to_wire(), and dns.message.Message.use_tsig().

◆ xfr

dns.message.Message.xfr

Definition at line 110 of file message.py.


The documentation for this class was generated from the following file: