1Fast(3) User Contributed Perl Documentation Fast(3)
2
3
4
6 Net::DNS::ZoneFile::Fast -- parse BIND8/9 zone files
7
9 use Net::DNS::ZoneFile::Fast;
10
11 my $rr = Net::DNS::ZoneFile::Fast::parse($zone_text);
12
14 The Net::DNS::ZoneFile::Fast module provides an ability to parse zone
15 files that BIND8 and BIND9 use, fast. Currently it provides a single
16 function, parse(), which returns a reference to an array of traditional
17 Net::DNS::RR objects, so that no new API has to be learned in order to
18 manipulate zone records.
19
20 Great care was taken to ensure that parse() does its job as fast as
21 possible, so it is interesting to use this module to parse huge zones.
22 As an example datapoint, it takes less than 5 seconds to parse a 2.2 MB
23 zone with about 72000 records on an Athlon XP 2600+ box.
24
25 On the other hand, it is likely that Net::DNS::RR objects that parse()
26 returns are going to be further processed. To make it easier to link
27 any record back to the zone file (say, to report a logical error like
28 infamous `CNAME and other data' back to the user, or to do a zone file
29 modification), parse() inserts line numbering information into
30 Net::DNS::RR objects.
31
32 The module currently understands:
33
34 $GENERATE directive
35 $ORIGIN directive
36 $TTL directive
37 $INCLUDE directive (only while processing files or filehandles)
38 A records
39 AAAA records
40 CNAME records
41 DNAME records
42 HINFO records
43 LOC records
44 MX records
45 NS records
46 PTR records
47 RP records
48 SOA records
49 SRV records
50 TXT records
51 RRSIG records
52 DNSKEY records
53 DS records
54 NSEC records
55 RRSIG records
56
57 Non-standard third-party modules
58 Net::DNS.
59
60 Exports
61 None.
62
63 Subroutines
64 parse
65 Parses zone data and returns a reference to an array of
66 Net::DNS::RR objects if successful. Takes the following named (no
67 pun intended) parameters:
68
69 text
70 A semi-mandatory parameter, textual contents of the zone to be
71 parsed.
72
73 fh A semi-mandatory parameter, a file handle from which zone
74 contents can be read for parsing.
75
76 file
77 A semi-mandatory parameter, a file name with the zone to parse.
78
79 origin
80 An optional parameter specifying zone origin. The default is
81 ".". A trailing "." is appended if necessary.
82
83 on_error
84 An optional parameter, user-defined error handler. If
85 specified, it must be a subroutine reference, which will be
86 called on any error. This subroutine will be passed two
87 parameters: a line number in the zone, where the error
88 occurred, and the error description.
89
90 soft_errors
91 By default, parse throws an exception on any error. Set this
92 optional parameter to a true value to avoid this. The default
93 is false, unless on_error is also specified, in which case it
94 is true.
95
96 includes_root
97 An optional parameter. By default, any $INCLUDE directives
98 encountered will be tested for existence and readability. If
99 the base path of the included filename is not your current
100 working directory, this test will fail. Set the includes_root
101 to the same as your named.conf file to avoid this failure.
102
103 quiet
104 An optional parameter. By default, on any error, the error
105 description is printed via warn(). Set quiet to a true value
106 if you don't want this. The default is false, unless on_error
107 is also specified, in which case it is true.
108
109 debug
110 An optional parameter. If set to true, will produce some debug
111 printing. You probably don't want to use that.
112
113 One of text, fh, file must be specified. If more than one is
114 specified at the same time, fh takes precedence over file, which
115 takes precedence over text.
116
117 As a special case, if parse is called with a single, unnamed
118 parameter, it is assumed to be a zone text.
119
120 If parse is unsuccessful, and does not throw an exception (because
121 either on_error or soft_errors was specified), parse returns undef.
122
123 The returned Net::DNS::RR are normal in every respect, except that
124 each of them has two extra keys, Line and Lines, which
125 correspondingly are the line number in the zone text where the
126 record starts, and the number of lines the record spans. This
127 information can be accessed either via hash lookup ("$rr->{Line}"),
128 or via an accessor method ("$rr->Line").
129
131 The parse() subroutine is not re-entrant, and it probably will never
132 be.
133
134 There is also no guarantee that parse() will successfully parse every
135 zone parsable by BIND, and no guarantee that BIND will parse every zone
136 parsable by parse(). That said, parse() appears to do the right thing
137 on around 50000 real life zones I tested it with.
138
139 SOA serial numbers with a decimal point are not supported (they're not
140 a legal zonefile contstruct, although bind8 supported them. Even bind
141 is dropping support for them in future releases).
142
144 Copyright 2003 by Anton Berezin and catpipe Systems ApS
145
146 "THE BEER-WARE LICENSE" (Revision 42)
147 <tobez@tobez.org> wrote this module. As long as you retain this notice
148 you can do whatever you want with this stuff. If we meet some day, and
149 you think this stuff is worth it, you can buy me a beer in return.
150
151 Anton Berezin
152
153 Copyright (c) 2004-2011 SPARTA, Inc.
154 All rights reserved.
155
156 Redistribution and use in source and binary forms, with or without
157 modification, are permitted provided that the following conditions are met:
158
159 * Redistributions of source code must retain the above copyright notice,
160 this list of conditions and the following disclaimer.
161
162 * Redistributions in binary form must reproduce the above copyright
163 notice, this list of conditions and the following disclaimer in the
164 documentation and/or other materials provided with the distribution.
165
166 * Neither the name of SPARTA, Inc nor the names of its contributors may
167 be used to endorse or promote products derived from this software
168 without specific prior written permission.
169
170 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
171 IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
172 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
173 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
174 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
175 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
176 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
177 OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
178 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
179 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
180 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
181
183 Anton Berezin created the versions up until 0.5. Wes Hardaker at
184 Sparta implemented the DNSSEC patches and took over maintenance of the
185 module from 0.6 onward.
186
187 Anton's original CREDITS section:
188
189 This module was largely inspired by the I<Net::DNS::ZoneFile> module
190 by Luis E. Munoz.
191
192 Many thanks to Phil Regnauld and Luis E. Munoz for discussions.
193
195 http://www.dnssec-tools.org/, Net::DNS(3), Net::DNS::RR(3),
196 Net::DNS::SEC(3)
197
198
199
200perl v5.12.4 2011-09-26 Fast(3)