message-class.rst 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. .. _message-class:
  2. The dns.message.Message Class
  3. -----------------------------
  4. .. autoclass:: dns.message.Message
  5. :members:
  6. .. attribute:: id
  7. An ``int``, the query id; the default is a randomly chosen id.
  8. .. attribute:: flags
  9. An ``int``, the DNS flags of the message.
  10. .. attribute:: question
  11. The question section, a list of ``dns.rrset.RRset`` objects.
  12. .. attribute:: answer
  13. The answer section, a list of ``dns.rrset.RRset`` objects.
  14. .. attribute:: authority
  15. The authority section, a list of ``dns.rrset.RRset`` objects.
  16. .. attribute:: additional
  17. The additional section, a list of ``dns.rrset.RRset`` objects.
  18. .. attribute:: edns
  19. An ``int``, the EDNS level to use. The default is -1, no EDNS.
  20. .. attribute:: ednsflags
  21. An ``int``, the EDNS flags.
  22. .. attribute:: payload
  23. An ``int``, the EDNS payload size. The default is 0.
  24. .. attribute:: options
  25. The EDNS options, a list of ``dns.edns.Option`` objects. The default
  26. is the empty list.
  27. .. attribute:: request_payload
  28. The associated request's EDNS payload size. This field is meaningful
  29. in response messages, and if set to a non-zero value, will limit
  30. the size of the response to the specified size. The default is 0,
  31. which means "use the default limit" which is currently 65535.
  32. .. attribute:: keyring
  33. The TSIG keyring to use. The default is `None`. A TSIG keyring
  34. is a dictionary mapping from TSIG key name, a ``dns.name.Name``, to
  35. a TSIG secret, a ``binary``.
  36. .. attribute:: keyname
  37. The TSIG keyname to use, a ``dns.name.Name``. The default is ``None``.
  38. .. attribute:: keyalgorithm
  39. A ``dns.name.Name``, the TSIG algorithm to use. Defaults to
  40. ``dns.tsig.default_algorithm``. Constants for TSIG algorithms are
  41. defined the in ``dns.tsig`` module.
  42. .. attribute:: request_mac
  43. A ``binary``, the TSIG MAC of the request message associated with
  44. this message; used when validating TSIG signatures.
  45. .. attribute:: fudge
  46. An ``int``, the TSIG time fudge. The default is 300 seconds.
  47. .. attribute:: original_id
  48. An ``int``, the TSIG original id; defaults to the message's id.
  49. .. attribute:: tsig_error
  50. An ``int``, the TSIG error code. The default is 0.
  51. .. attribute:: other_data
  52. A ``binary``, the TSIG "other data". The default is the empty
  53. ``binary``.
  54. .. attribute:: mac
  55. A ``binary``, the TSIG MAC for this message.
  56. .. attribute:: xfr
  57. A ``bool``. This attribute is true when the message being used
  58. for the results of a DNS zone transfer. The default is ``False``.
  59. .. attribute:: origin
  60. A ``dns.name.Name``. The origin of the zone in messages which are
  61. used for zone transfers or for DNS dynamic updates. The default
  62. is ``None``.
  63. .. attribute:: tsig_ctx
  64. An ``hmac.HMAC``, the TSIG signature context associated with this
  65. message. The default is ``None``.
  66. .. attribute:: had_tsig
  67. A ``bool``, which is ``True`` if the message had a TSIG signature
  68. when it was decoded from wire format.
  69. .. attribute:: multi
  70. A ``bool``, which is ``True`` if this message is part of a
  71. multi-message sequence. The default is ``False``.
  72. This attribute is used when validating TSIG signatures
  73. on messages which are part of a zone transfer.
  74. .. attribute:: first
  75. A ``bool``, which is ``True`` if this message is stand-alone,
  76. or the first of a multi-message sequence. The default is ``True``.
  77. This variable is used when validating TSIG signatures
  78. on messages which are part of a zone transfer.
  79. .. attribute:: index
  80. A ``dict``, an index of RRsets in the message. The index key is
  81. ``(section, name, rdclass, rdtype, covers, deleting)``. The default
  82. is ``{}``. Indexing improves the performance of finding RRsets.
  83. Indexing can be disabled by setting the index to ``None``.
  84. The following constants may be used to specify sections in the
  85. ``find_rrset()`` and ``get_rrset()`` methods:
  86. .. autodata:: dns.message.QUESTION
  87. .. autodata:: dns.message.ANSWER
  88. .. autodata:: dns.message.AUTHORITY
  89. .. autodata:: dns.message.ADDITIONAL