summaryrefslogtreecommitdiff
path: root/doc/zonefile.rst
blob: abf1c53e00dee4c0f4a46f21812c4b576ff8313c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
.. _zonefile:

The RRSet Reader
----------------

``dns.zonefile.read_rrsets()`` reads one or more RRsets from text format.  It
is designed to be used in situations where you are processing DNS data in
text format, but do not want or need a valid zone.  For example, a DNS registry
web application might want to allow the user to input RRs.

.. autofunction:: dns.zonefile.read_rrsets


Examples
========

Read RRSets with name, TTL, and rdclass forced::

  input = '''
  mx 10 a
  mx 20 b
  ns ns1
  '''
  rrsets = dns.read_rrsets(input, name='name', ttl=300)

Read RRSets with name, TTL, rdclass, and rdtype forced::

  input = '''
  10 a
  20 b
  '''
  rrsets = dns.read_rrsets(input, name='name', ttl=300, rdtype='mx')

Note that in this case the length of rrsets will always be one.

Read relativized RRsets with unforced rdclass (but which must match
default_rdclass)::

  input = '''
  name1 20 MX 10 a.example.
  name2 30 IN MX 20 b
  '''
  rrsets = dns.read_rrsets(input, origin='example', relativize=True,
                           rdclass=None)

The dns.zonefile.Reader Class
=============================

The ``Reader`` class reads data in DNS zonefile format, or various
restrictions of that format, and converts it to a sequence of operations
in a transaction.

This class is primarily used by ``dns.zone.Zone.from_text()`` and
``dns.zonefile.read_rrsets``, but may be useful for other software which needs
to process the zonefile format.

.. autoclass:: dns.zonefile.Reader
   :members: