dns-zonefile 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/doc/zonefile.treetop +80 -17
- data/lib/dns/zonefile.rb +1 -0
- data/lib/dns/zonefile/parser.rb +817 -444
- data/lib/dns/zonefile/version.rb +1 -1
- data/spec/dns/zonefile_spec.rb +58 -8
- metadata +2 -2
data/lib/dns/zonefile/version.rb
CHANGED
data/spec/dns/zonefile_spec.rb
CHANGED
@@ -65,15 +65,22 @@ _xmpp-server._tcp SRV 5 0 5269 xmpp-server.l.google.com. ; SRV record
|
|
65
65
|
|
66
66
|
; TXT record, with embedded semicolons
|
67
67
|
_domainkey TXT "v=DKIM1\\;g=*\\;k=rsa\\; p=4tkw1bbkfa0ahfjgnbewr2ttkvahvfmfizowl9s4g0h28io76ndow25snl9iumpcv0jwxr2k"
|
68
|
+
with_ms_txt TXT ( "Some text" )
|
68
69
|
|
69
70
|
@ TXT "some other \\"message\\" goes here" ; embedded quotes
|
70
71
|
long TXT "a multi-segment TXT record" "usually used for really long TXT records" "since each segment can only span 255 chars"
|
71
72
|
unquoted TXT some text data
|
72
73
|
|
73
74
|
multiline TXT "A TXT record
|
74
|
-
split across multiple lines
|
75
|
+
split across multiple lines
|
75
76
|
with LF and CRLF line endings"
|
76
77
|
|
78
|
+
; Microsoft AD DNS Examples with Aging.
|
79
|
+
with-age [AGE:999992222] 60 A 10.0.0.7 ; with a specified AGE
|
80
|
+
with-age-aaaa [AGE:999992222] 60 AAAA 10.0.0.8 ; with a specified AGE
|
81
|
+
_ldap._tcp.pupy._sites.dc._msdcs [AGE:3636525] 600 SRV 0 100 389 host01.ad
|
82
|
+
P229392922 [AGE:3636449] 172800 CNAME printer01.ad
|
83
|
+
|
77
84
|
@ SPF "v=spf1 a a:other.domain.com ~all"
|
78
85
|
|
79
86
|
45 IN PTR @
|
@@ -132,7 +139,7 @@ ZONE
|
|
132
139
|
|
133
140
|
it "should build the correct number of resource records" do
|
134
141
|
zone = DNS::Zonefile.parse(@zonefile)
|
135
|
-
zone.rr.size.should be(
|
142
|
+
zone.rr.size.should be(49)
|
136
143
|
end
|
137
144
|
|
138
145
|
it "should build the correct NS records" do
|
@@ -152,7 +159,7 @@ ZONE
|
|
152
159
|
it "should build the correct A records" do
|
153
160
|
zone = DNS::Zonefile.load(@zonefile)
|
154
161
|
a_records = zone.records_of DNS::Zonefile::A
|
155
|
-
a_records.size.should be(
|
162
|
+
a_records.size.should be(13)
|
156
163
|
|
157
164
|
a_records.detect { |a|
|
158
165
|
a.host == "example.com." && a.address == "10.0.0.1"
|
@@ -190,6 +197,10 @@ ZONE
|
|
190
197
|
a.host == "with-ttl.example.com." && a.address == "10.0.0.5" && a.ttl == 60
|
191
198
|
}.should_not be_nil
|
192
199
|
|
200
|
+
a_records.detect { |a|
|
201
|
+
a.host == "with-age.example.com." && a.address == "10.0.0.7" && a.ttl == 60
|
202
|
+
}.should_not be_nil
|
203
|
+
|
193
204
|
a_records.detect { |a|
|
194
205
|
a.host == "ttl-class.example.com." && a.address == "10.0.0.6" && a.ttl == 60
|
195
206
|
}.should_not be_nil
|
@@ -206,7 +217,7 @@ ZONE
|
|
206
217
|
it "should build the correct CNAME records" do
|
207
218
|
zone = DNS::Zonefile.load(@zonefile)
|
208
219
|
cname_records = zone.records_of DNS::Zonefile::CNAME
|
209
|
-
cname_records.size.should be(
|
220
|
+
cname_records.size.should be(9)
|
210
221
|
|
211
222
|
cname_records.detect { |cname|
|
212
223
|
cname.host == "www.example.com." && cname.target == "ns.example.com."
|
@@ -220,6 +231,10 @@ ZONE
|
|
220
231
|
cname.host == "www2.example.com." && cname.domainname == "ns.example.com." && cname.ttl == 86400
|
221
232
|
}.should_not be_nil
|
222
233
|
|
234
|
+
cname_records.detect { |cname|
|
235
|
+
cname.host == "P229392922.example.com." && cname.domainname == "printer01.ad.example.com." && cname.ttl == 172800
|
236
|
+
}.should_not be_nil
|
237
|
+
|
223
238
|
eam_records = cname_records.select { |c| c.host =~ /eam\./ }
|
224
239
|
|
225
240
|
eam_records.should have(5).records
|
@@ -258,7 +273,7 @@ ZONE
|
|
258
273
|
it "should build the correct AAAA records" do
|
259
274
|
zone = DNS::Zonefile.load(@zonefile)
|
260
275
|
aaaa_records = zone.records_of DNS::Zonefile::AAAA
|
261
|
-
aaaa_records.size.should be(
|
276
|
+
aaaa_records.size.should be(4)
|
262
277
|
|
263
278
|
aaaa_records.detect { |a|
|
264
279
|
a.host == "example.com." && a.address == "2001:db8:a::1"
|
@@ -271,6 +286,11 @@ ZONE
|
|
271
286
|
aaaa_records.detect { |a|
|
272
287
|
a.host == "mail.example.com." && a.address == "2001:db8:c::10.0.0.4" && a.ttl == 86400
|
273
288
|
}.should_not be_nil
|
289
|
+
|
290
|
+
aaaa_records.detect { |a|
|
291
|
+
a.host == "with-age-aaaa.example.com." && a.address == "10.0.0.8" && a.ttl == 60
|
292
|
+
}.should_not be_nil
|
293
|
+
|
274
294
|
end
|
275
295
|
|
276
296
|
it "should build the correct NAPTR records" do
|
@@ -290,12 +310,16 @@ ZONE
|
|
290
310
|
it "should build the correct SRV records" do
|
291
311
|
zone = DNS::Zonefile.load(@zonefile)
|
292
312
|
srv_records = zone.records_of DNS::Zonefile::SRV
|
293
|
-
srv_records.size.should be(
|
313
|
+
srv_records.size.should be(7)
|
294
314
|
|
295
315
|
srv_records.detect { |r|
|
296
316
|
r.host == "_xmpp-server._tcp.example.com." && r.priority == 5 && r.weight == 0 && r.port == 5269 && r.target == 'xmpp-server.l.google.com.' && r.ttl == 86400
|
297
317
|
}.should_not be_nil
|
298
318
|
|
319
|
+
srv_records.detect { |r|
|
320
|
+
r.host == "_ldap._tcp.pupy._sites.dc._msdcs.example.com." && r.priority == 0 && r.weight == 100 && r.port == 389 && r.target == 'host01.ad.example.com.' && r.ttl == 600
|
321
|
+
}.should_not be_nil
|
322
|
+
|
299
323
|
eam_records = srv_records.select { |s| s.host =~ /eam\./ }
|
300
324
|
eam_records.should have(5).records
|
301
325
|
eam_records.each { |srv|
|
@@ -313,12 +337,16 @@ ZONE
|
|
313
337
|
it "should build the correct TXT records" do
|
314
338
|
zone = DNS::Zonefile.load(@zonefile)
|
315
339
|
txt_records = zone.records_of DNS::Zonefile::TXT
|
316
|
-
txt_records.size.should be(
|
340
|
+
txt_records.size.should be(6)
|
317
341
|
|
318
342
|
txt_records.detect { |r|
|
319
343
|
r.host == "_domainkey.example.com." && r.data == '"v=DKIM1\;g=*\;k=rsa\; p=4tkw1bbkfa0ahfjgnbewr2ttkvahvfmfizowl9s4g0h28io76ndow25snl9iumpcv0jwxr2k"'
|
320
344
|
}.should_not be_nil
|
321
345
|
|
346
|
+
txt_records.detect { |r|
|
347
|
+
r.host == "with_ms_txt.example.com." && r.data == '"Some text"'
|
348
|
+
}.should_not be_nil
|
349
|
+
|
322
350
|
txt_records.detect { |r|
|
323
351
|
r.host == "example.com." && r.data == '"some other \"message\" goes here"' && r.ttl == 86400
|
324
352
|
}.should_not be_nil
|
@@ -348,7 +376,7 @@ ZONE
|
|
348
376
|
|
349
377
|
it "should build the correct PTR records" do
|
350
378
|
zone = DNS::Zonefile.load(@zonefile)
|
351
|
-
ptr_records = zone.records_of DNS::Zonefile::PTR
|
379
|
+
ptr_records = zone.records_of DNS::Zonefile::PTR
|
352
380
|
ptr_records.size.should be(1)
|
353
381
|
|
354
382
|
ptr_records.detect { |r|
|
@@ -381,4 +409,26 @@ ZONE
|
|
381
409
|
soa.nxttl.should eql(180)
|
382
410
|
end
|
383
411
|
end
|
412
|
+
|
413
|
+
describe "parsing an SOA with just . for responsible party" do
|
414
|
+
before(:each) do
|
415
|
+
@zonefile =<<-ZONE
|
416
|
+
@ IN SOA ns.domain.example.com. . (
|
417
|
+
2007120710 ; serial number of this zone file
|
418
|
+
1d ; slave refresh (1 day)
|
419
|
+
1d ; slave retry time in case of a problem (1 day)
|
420
|
+
4W ; slave expiration time (4 weeks)
|
421
|
+
3600 ; minimum caching time in case of failed lookups (1 hour)
|
422
|
+
)
|
423
|
+
ZONE
|
424
|
+
end
|
425
|
+
|
426
|
+
it "should parse the SOA record correctly" do
|
427
|
+
zone = DNS::Zonefile.load(@zonefile)
|
428
|
+
soa = zone.soa
|
429
|
+
soa.klass.should eql('IN')
|
430
|
+
soa.nameserver.should eql('ns.domain.example.com.')
|
431
|
+
soa.responsible_party.should eql('.')
|
432
|
+
end
|
433
|
+
end
|
384
434
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dns-zonefile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Craig R Webster
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|