net-dns 0.8.0 → 0.20.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/.rspec +1 -0
- data/.travis.yml +9 -16
- data/CHANGELOG.md +37 -13
- data/LICENSE.txt +56 -0
- data/README.md +94 -77
- data/demo/check_soa.rb +27 -38
- data/demo/threads.rb +3 -7
- data/lib/net/dns/header.rb +86 -110
- data/lib/net/dns/names.rb +31 -31
- data/lib/net/dns/packet.rb +148 -158
- data/lib/net/dns/question.rb +41 -42
- data/lib/net/dns/resolver/socks.rb +47 -55
- data/lib/net/dns/resolver/timeouts.rb +19 -30
- data/lib/net/dns/resolver.rb +151 -176
- data/lib/net/dns/rr/a.rb +45 -55
- data/lib/net/dns/rr/aaaa.rb +39 -50
- data/lib/net/dns/rr/classes.rb +32 -37
- data/lib/net/dns/rr/cname.rb +31 -41
- data/lib/net/dns/rr/hinfo.rb +40 -56
- data/lib/net/dns/rr/mr.rb +31 -42
- data/lib/net/dns/rr/mx.rb +35 -47
- data/lib/net/dns/rr/ns.rb +31 -41
- data/lib/net/dns/rr/null.rb +10 -15
- data/lib/net/dns/rr/ptr.rb +16 -24
- data/lib/net/dns/rr/soa.rb +36 -35
- data/lib/net/dns/rr/srv.rb +18 -19
- data/lib/net/dns/rr/txt.rb +11 -16
- data/lib/net/dns/rr/types.rb +118 -109
- data/lib/net/dns/rr.rb +107 -117
- data/lib/net/dns/version.rb +5 -13
- data/lib/net/dns.rb +6 -11
- metadata +18 -83
- data/.gitignore +0 -8
- data/Gemfile +0 -4
- data/Rakefile +0 -71
- data/fixtures/resolv.conf +0 -4
- data/lib/net/dns/core_ext.rb +0 -52
- data/net-dns.gemspec +0 -35
- data/test/header_test.rb +0 -167
- data/test/names_test.rb +0 -21
- data/test/packet_test.rb +0 -49
- data/test/question_test.rb +0 -83
- data/test/resolver/timeouts_test.rb +0 -109
- data/test/resolver_test.rb +0 -117
- data/test/rr/a_test.rb +0 -113
- data/test/rr/aaaa_test.rb +0 -109
- data/test/rr/classes_test.rb +0 -85
- data/test/rr/cname_test.rb +0 -97
- data/test/rr/hinfo_test.rb +0 -117
- data/test/rr/mr_test.rb +0 -105
- data/test/rr/mx_test.rb +0 -112
- data/test/rr/ns_test.rb +0 -86
- data/test/rr/types_test.rb +0 -69
- data/test/rr_test.rb +0 -131
- data/test/test_helper.rb +0 -4
data/lib/net/dns/packet.rb
CHANGED
@@ -6,7 +6,6 @@ require 'net/dns/rr'
|
|
6
6
|
|
7
7
|
module Net
|
8
8
|
module DNS
|
9
|
-
|
10
9
|
#
|
11
10
|
# = Net::DNS::Packet
|
12
11
|
#
|
@@ -91,9 +90,13 @@ module Net
|
|
91
90
|
class PacketError < Error
|
92
91
|
end
|
93
92
|
|
94
|
-
|
95
|
-
attr_reader :
|
96
|
-
attr_reader :
|
93
|
+
attr_reader :header
|
94
|
+
attr_reader :question
|
95
|
+
attr_reader :answer
|
96
|
+
attr_reader :authority
|
97
|
+
attr_reader :additional
|
98
|
+
attr_reader :answerfrom
|
99
|
+
attr_reader :answersize
|
97
100
|
|
98
101
|
# Creates a new instance of <tt>Net::DNS::Packet</tt> class. Arguments are the
|
99
102
|
# canonical name of the resource, an optional type field and an optional
|
@@ -107,7 +110,7 @@ module Net
|
|
107
110
|
# This class no longer instantiate object from binary data coming from
|
108
111
|
# network streams. Please use <tt>Net::DNS::Packet.parse</tt> instead.
|
109
112
|
def initialize(name, type = Net::DNS::A, cls = Net::DNS::IN)
|
110
|
-
@header = Net::DNS::Header.new(:
|
113
|
+
@header = Net::DNS::Header.new(qdCount: 1)
|
111
114
|
@question = [Net::DNS::Question.new(name, type, cls)]
|
112
115
|
@answer = []
|
113
116
|
@authority = []
|
@@ -116,7 +119,6 @@ module Net
|
|
116
119
|
@logger.level = $DEBUG ? Logger::DEBUG : Logger::WARN
|
117
120
|
end
|
118
121
|
|
119
|
-
|
120
122
|
# Checks if the packet is a QUERY packet
|
121
123
|
def query?
|
122
124
|
@header.opCode == Net::DNS::Header::QUERY
|
@@ -129,7 +131,7 @@ module Net
|
|
129
131
|
# puts "Packet is #{packet_data.size} bytes long"
|
130
132
|
#
|
131
133
|
def data
|
132
|
-
qdcount=ancount=nscount=arcount=0
|
134
|
+
qdcount = ancount = nscount = arcount = 0
|
133
135
|
data = @header.data
|
134
136
|
headerlength = data.length
|
135
137
|
|
@@ -138,15 +140,15 @@ module Net
|
|
138
140
|
qdcount += 1
|
139
141
|
end
|
140
142
|
@answer.each do |rr|
|
141
|
-
data += rr.data#(data.length)
|
143
|
+
data += rr.data # (data.length)
|
142
144
|
ancount += 1
|
143
145
|
end
|
144
146
|
@authority.each do |rr|
|
145
|
-
data += rr.data#(data.length)
|
147
|
+
data += rr.data # (data.length)
|
146
148
|
nscount += 1
|
147
149
|
end
|
148
150
|
@additional.each do |rr|
|
149
|
-
data += rr.data#(data.length)
|
151
|
+
data += rr.data # (data.length)
|
150
152
|
arcount += 1
|
151
153
|
end
|
152
154
|
|
@@ -168,33 +170,33 @@ module Net
|
|
168
170
|
def data_comp
|
169
171
|
offset = 0
|
170
172
|
compnames = {}
|
171
|
-
qdcount=ancount=nscount=arcount=0
|
173
|
+
qdcount = ancount = nscount = arcount = 0
|
172
174
|
data = @header.data
|
173
175
|
headerlength = data.length
|
174
176
|
|
175
177
|
@question.each do |question|
|
176
|
-
str,offset,names = question.data
|
178
|
+
str, offset, names = question.data
|
177
179
|
data += str
|
178
180
|
compnames.update(names)
|
179
181
|
qdcount += 1
|
180
182
|
end
|
181
183
|
|
182
184
|
@answer.each do |rr|
|
183
|
-
str,offset,names = rr.data(offset,compnames)
|
185
|
+
str, offset, names = rr.data(offset, compnames)
|
184
186
|
data += str
|
185
187
|
compnames.update(names)
|
186
188
|
ancount += 1
|
187
189
|
end
|
188
190
|
|
189
191
|
@authority.each do |rr|
|
190
|
-
str,offset,names = rr.data(offset,compnames)
|
192
|
+
str, offset, names = rr.data(offset, compnames)
|
191
193
|
data += str
|
192
194
|
compnames.update(names)
|
193
195
|
nscount += 1
|
194
196
|
end
|
195
197
|
|
196
198
|
@additional.each do |rr|
|
197
|
-
str,offset,names = rr.data(offset,compnames)
|
199
|
+
str, offset, names = rr.data(offset, compnames)
|
198
200
|
data += str
|
199
201
|
compnames.update(names)
|
200
202
|
arcount += 1
|
@@ -212,39 +214,39 @@ module Net
|
|
212
214
|
# of this <tt>Net::DNS::Packet</tt> instance.
|
213
215
|
def inspect
|
214
216
|
retval = ""
|
215
|
-
if @answerfrom != "0.0.0.0:0"
|
216
|
-
retval += ";; Answer received from
|
217
|
+
if (@answerfrom != "0.0.0.0:0") && @answerfrom
|
218
|
+
retval += ";; Answer received from #{@answerfrom} (#{@answersize} bytes)\n;;\n"
|
217
219
|
end
|
218
220
|
|
219
221
|
retval += ";; HEADER SECTION\n"
|
220
222
|
retval += @header.inspect
|
221
223
|
|
222
224
|
retval += "\n"
|
223
|
-
section =
|
225
|
+
section = @header.opCode == "UPDATE" ? "ZONE" : "QUESTION"
|
224
226
|
retval += ";; #{section} SECTION (#{@header.qdCount} record#{@header.qdCount == 1 ? '' : 's'}):\n"
|
225
227
|
@question.each do |qr|
|
226
228
|
retval += ";; " + qr.inspect + "\n"
|
227
229
|
end
|
228
230
|
|
229
|
-
unless @answer.
|
231
|
+
unless @answer.empty?
|
230
232
|
retval += "\n"
|
231
|
-
section =
|
233
|
+
section = @header.opCode == "UPDATE" ? "PREREQUISITE" : "ANSWER"
|
232
234
|
retval += ";; #{section} SECTION (#{@header.anCount} record#{@header.anCount == 1 ? '' : 's'}):\n"
|
233
235
|
@answer.each do |rr|
|
234
236
|
retval += rr.inspect + "\n"
|
235
237
|
end
|
236
238
|
end
|
237
239
|
|
238
|
-
unless @authority.
|
240
|
+
unless @authority.empty?
|
239
241
|
retval += "\n"
|
240
|
-
section =
|
242
|
+
section = @header.opCode == "UPDATE" ? "UPDATE" : "AUTHORITY"
|
241
243
|
retval += ";; #{section} SECTION (#{@header.nsCount} record#{@header.nsCount == 1 ? '' : 's'}):\n"
|
242
244
|
@authority.each do |rr|
|
243
245
|
retval += rr.inspect + "\n"
|
244
246
|
end
|
245
247
|
end
|
246
248
|
|
247
|
-
unless @additional.
|
249
|
+
unless @additional.empty?
|
248
250
|
retval += "\n"
|
249
251
|
retval += ";; ADDITIONAL SECTION (#{@header.arCount} record#{@header.arCount == 1 ? '' : 's'}):\n"
|
250
252
|
@additional.each do |rr|
|
@@ -254,7 +256,7 @@ module Net
|
|
254
256
|
|
255
257
|
retval
|
256
258
|
end
|
257
|
-
|
259
|
+
alias to_s inspect
|
258
260
|
|
259
261
|
# Delegates to <tt>Net::DNS::Header#truncated?</tt>.
|
260
262
|
def truncated?
|
@@ -264,11 +266,9 @@ module Net
|
|
264
266
|
# Assigns a <tt>Net::DNS::Header</tt> <tt>object</tt>
|
265
267
|
# to this <tt>Net::DNS::Packet</tt> instance.
|
266
268
|
def header=(object)
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
raise ArgumentError, "Argument must be a Net::DNS::Header object"
|
271
|
-
end
|
269
|
+
raise ArgumentError, "Argument must be a Net::DNS::Header object" unless object.is_a? Net::DNS::Header
|
270
|
+
|
271
|
+
@header = object
|
272
272
|
end
|
273
273
|
|
274
274
|
# Assigns a <tt>Net::DNS::Question</tt> <tt>object</tt>
|
@@ -276,11 +276,10 @@ module Net
|
|
276
276
|
def question=(object)
|
277
277
|
case object
|
278
278
|
when Array
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
end
|
279
|
+
raise ArgumentError, "Some of the elements is not an Net::DNS::Question object" unless object.all? { |x| x.is_a? Net::DNS::Question }
|
280
|
+
|
281
|
+
@question = object
|
282
|
+
|
284
283
|
when Net::DNS::Question
|
285
284
|
@question = [object]
|
286
285
|
else
|
@@ -292,16 +291,15 @@ module Net
|
|
292
291
|
# to the answer section of this <tt>Net::DNS::Packet</tt> instance.
|
293
292
|
def answer=(object)
|
294
293
|
case object
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
raise ArgumentError, "Invalid argument, not a RR object nor an array of objects"
|
294
|
+
when Array
|
295
|
+
raise ArgumentError, "Some of the elements is not an Net::DNS::RR object" unless object.all? { |x| x.is_a? Net::DNS::RR }
|
296
|
+
|
297
|
+
@answer = object
|
298
|
+
|
299
|
+
when Net::DNS::RR
|
300
|
+
@answer = [object]
|
301
|
+
else
|
302
|
+
raise ArgumentError, "Invalid argument, not a RR object nor an array of objects"
|
305
303
|
end
|
306
304
|
end
|
307
305
|
|
@@ -309,16 +307,15 @@ module Net
|
|
309
307
|
# to the additional section of this <tt>Net::DNS::Packet</tt> instance.
|
310
308
|
def additional=(object)
|
311
309
|
case object
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
raise ArgumentError, "Invalid argument, not a RR object nor an array of objects"
|
310
|
+
when Array
|
311
|
+
raise ArgumentError, "Some of the elements is not an Net::DNS::RR object" unless object.all? { |x| x.is_a? Net::DNS::RR }
|
312
|
+
|
313
|
+
@additional = object
|
314
|
+
|
315
|
+
when Net::DNS::RR
|
316
|
+
@additional = [object]
|
317
|
+
else
|
318
|
+
raise ArgumentError, "Invalid argument, not a RR object nor an array of objects"
|
322
319
|
end
|
323
320
|
end
|
324
321
|
|
@@ -326,16 +323,15 @@ module Net
|
|
326
323
|
# to the authority section of this <tt>Net::DNS::Packet</tt> instance.
|
327
324
|
def authority=(object)
|
328
325
|
case object
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
raise ArgumentError, "Invalid argument, not a RR object nor an array of objects"
|
326
|
+
when Array
|
327
|
+
raise ArgumentError, "Some of the elements is not an Net::DNS::RR object" unless object.all? { |x| x.is_a? Net::DNS::RR }
|
328
|
+
|
329
|
+
@authority = object
|
330
|
+
|
331
|
+
when Net::DNS::RR
|
332
|
+
@authority = [object]
|
333
|
+
else
|
334
|
+
raise ArgumentError, "Invalid argument, not a RR object nor an array of objects"
|
339
335
|
end
|
340
336
|
end
|
341
337
|
|
@@ -348,9 +344,10 @@ module Net
|
|
348
344
|
#
|
349
345
|
# As you can see in the documentation for the <tt>Net::DNS::RR::A</tt> class,
|
350
346
|
# the address returned is an instance of <tt>IPAddr</tt> class.
|
351
|
-
def each_address
|
347
|
+
def each_address
|
352
348
|
@answer.each do |elem|
|
353
349
|
next unless elem.class == Net::DNS::RR::A
|
350
|
+
|
354
351
|
yield elem.address
|
355
352
|
end
|
356
353
|
end
|
@@ -362,9 +359,10 @@ module Net
|
|
362
359
|
# puts "Nameserver found: #{ns}"
|
363
360
|
# end
|
364
361
|
#
|
365
|
-
def each_nameserver
|
362
|
+
def each_nameserver
|
366
363
|
@answer.each do |elem|
|
367
364
|
next unless elem.class == Net::DNS::RR::NS
|
365
|
+
|
368
366
|
yield elem.nsdname
|
369
367
|
end
|
370
368
|
end
|
@@ -376,9 +374,10 @@ module Net
|
|
376
374
|
# puts "Mail exchange #{name} has preference #{pref}"
|
377
375
|
# end
|
378
376
|
#
|
379
|
-
def each_mx
|
377
|
+
def each_mx
|
380
378
|
@answer.each do |elem|
|
381
379
|
next unless elem.class == Net::DNS::RR::MX
|
380
|
+
|
382
381
|
yield elem.preference, elem.exchange
|
383
382
|
end
|
384
383
|
end
|
@@ -390,9 +389,10 @@ module Net
|
|
390
389
|
# puts "Canonical name: #{cname}"
|
391
390
|
# end
|
392
391
|
#
|
393
|
-
def each_cname
|
392
|
+
def each_cname
|
394
393
|
@answer.each do |elem|
|
395
394
|
next unless elem.class == Net::DNS::RR::CNAME
|
395
|
+
|
396
396
|
yield elem.cname
|
397
397
|
end
|
398
398
|
end
|
@@ -404,9 +404,10 @@ module Net
|
|
404
404
|
# puts "Pointer for resource: #{ptr}"
|
405
405
|
# end
|
406
406
|
#
|
407
|
-
def each_ptr
|
407
|
+
def each_ptr
|
408
408
|
@answer.each do |elem|
|
409
409
|
next unless elem.class == Net::DNS::RR::PTR
|
410
|
+
|
410
411
|
yield elem.ptrdname
|
411
412
|
end
|
412
413
|
end
|
@@ -436,7 +437,6 @@ module Net
|
|
436
437
|
header.rCode.code == Net::DNS::Header::RCode::NAME
|
437
438
|
end
|
438
439
|
|
439
|
-
|
440
440
|
# Creates a new instance of <tt>Net::DNS::Packet</tt> class from binary data,
|
441
441
|
# taken out from a network stream. For example:
|
442
442
|
#
|
@@ -459,105 +459,95 @@ module Net
|
|
459
459
|
|
460
460
|
private
|
461
461
|
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
end
|
462
|
+
# New packet from binary data
|
463
|
+
def new_from_data(data, from = nil)
|
464
|
+
unless from
|
465
|
+
if data.is_a? Array
|
466
|
+
data, from = data
|
467
|
+
else
|
468
|
+
from = [0, 0, "0.0.0.0", "unknown"]
|
470
469
|
end
|
470
|
+
end
|
471
471
|
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
#------------------------------------------------------------
|
478
|
-
# Header section
|
479
|
-
#------------------------------------------------------------
|
480
|
-
offset = Net::DNS::HFIXEDSZ
|
481
|
-
@header = Net::DNS::Header.parse(data[0..offset-1])
|
482
|
-
|
483
|
-
@logger.debug ";; HEADER SECTION"
|
484
|
-
@logger.debug @header.inspect
|
485
|
-
|
486
|
-
#------------------------------------------------------------
|
487
|
-
# Question section
|
488
|
-
#------------------------------------------------------------
|
489
|
-
section = @header.opCode == "UPDATE" ? "ZONE" : "QUESTION"
|
490
|
-
@logger.debug ";; #{section} SECTION (#{@header.qdCount} record#{@header.qdCount == 1 ? '': 's'})"
|
491
|
-
|
492
|
-
@question = []
|
493
|
-
@header.qdCount.times do
|
494
|
-
qobj,offset = parse_question(data,offset)
|
495
|
-
@question << qobj
|
496
|
-
@logger.debug ";; #{qobj.inspect}"
|
497
|
-
end
|
472
|
+
@answerfrom = from[2] + ":" + from[1].to_s
|
473
|
+
@answersize = data.size
|
474
|
+
@logger = Logger.new $stdout
|
475
|
+
@logger.level = $DEBUG ? Logger::DEBUG : Logger::WARN
|
498
476
|
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
477
|
+
#------------------------------------------------------------
|
478
|
+
# Header section
|
479
|
+
#------------------------------------------------------------
|
480
|
+
offset = Net::DNS::HFIXEDSZ
|
481
|
+
@header = Net::DNS::Header.parse(data[0..offset - 1])
|
482
|
+
|
483
|
+
@logger.debug ";; HEADER SECTION"
|
484
|
+
@logger.debug @header.inspect
|
485
|
+
|
486
|
+
#------------------------------------------------------------
|
487
|
+
# Question section
|
488
|
+
#------------------------------------------------------------
|
489
|
+
section = @header.opCode == "UPDATE" ? "ZONE" : "QUESTION"
|
490
|
+
@logger.debug ";; #{section} SECTION (#{@header.qdCount} record#{@header.qdCount == 1 ? '' : 's'})"
|
491
|
+
|
492
|
+
@question = []
|
493
|
+
@header.qdCount.times do
|
494
|
+
qobj, offset = parse_question(data, offset)
|
495
|
+
@question << qobj
|
496
|
+
@logger.debug ";; #{qobj.inspect}"
|
497
|
+
end
|
515
498
|
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
@authority = []
|
523
|
-
@header.nsCount.times do
|
524
|
-
begin
|
525
|
-
rrobj,offset = Net::DNS::RR.parse_packet(data,offset)
|
526
|
-
@authority << rrobj
|
527
|
-
@logger.debug rrobj.inspect
|
528
|
-
rescue NameError => e
|
529
|
-
warn "Net::DNS unsupported record type: #{e.message}"
|
530
|
-
end
|
531
|
-
end
|
499
|
+
#------------------------------------------------------------
|
500
|
+
# Answer/prerequisite section
|
501
|
+
#------------------------------------------------------------
|
502
|
+
section = @header.opCode == "UPDATE" ? "PREREQUISITE" : "ANSWER"
|
503
|
+
@logger.debug ";; #{section} SECTION (#{@header.qdCount} record#{@header.qdCount == 1 ? '' : 's'})"
|
532
504
|
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
@
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
rrobj,offset = Net::DNS::RR.parse_packet(data,offset)
|
542
|
-
@additional << rrobj
|
543
|
-
@logger.debug rrobj.inspect
|
544
|
-
rescue NameError => e
|
545
|
-
warn "Net::DNS supported record type: #{e.message}"
|
546
|
-
end
|
547
|
-
end
|
505
|
+
@answer = []
|
506
|
+
@header.anCount.times do
|
507
|
+
rrobj, offset = Net::DNS::RR.parse_packet(data, offset)
|
508
|
+
@answer << rrobj
|
509
|
+
@logger.debug rrobj.inspect
|
510
|
+
rescue NameError => e
|
511
|
+
warn "Net::DNS unsupported record type: #{e.message}"
|
512
|
+
end
|
548
513
|
|
514
|
+
#------------------------------------------------------------
|
515
|
+
# Authority/update section
|
516
|
+
#------------------------------------------------------------
|
517
|
+
section = @header.opCode == "UPDATE" ? "UPDATE" : "AUTHORITY"
|
518
|
+
@logger.debug ";; #{section} SECTION (#{@header.nsCount} record#{@header.nsCount == 1 ? '' : 's'})"
|
519
|
+
|
520
|
+
@authority = []
|
521
|
+
@header.nsCount.times do
|
522
|
+
rrobj, offset = Net::DNS::RR.parse_packet(data, offset)
|
523
|
+
@authority << rrobj
|
524
|
+
@logger.debug rrobj.inspect
|
525
|
+
rescue NameError => e
|
526
|
+
warn "Net::DNS unsupported record type: #{e.message}"
|
549
527
|
end
|
550
528
|
|
529
|
+
#------------------------------------------------------------
|
530
|
+
# Additional section
|
531
|
+
#------------------------------------------------------------
|
532
|
+
@logger.debug ";; ADDITIONAL SECTION (#{@header.arCount} record#{@header.arCount == 1 ? '' : 's'})"
|
551
533
|
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
534
|
+
@additional = []
|
535
|
+
@header.arCount.times do
|
536
|
+
rrobj, offset = Net::DNS::RR.parse_packet(data, offset)
|
537
|
+
@additional << rrobj
|
538
|
+
@logger.debug rrobj.inspect
|
539
|
+
rescue NameError => e
|
540
|
+
warn "Net::DNS unsupported record type: #{e.message}"
|
558
541
|
end
|
542
|
+
end
|
559
543
|
|
544
|
+
# Parse question section
|
545
|
+
def parse_question(data, offset)
|
546
|
+
size = (dn_expand(data, offset)[1] - offset) + (2 * Net::DNS::INT16SZ)
|
547
|
+
[Net::DNS::Question.parse(data[offset, size]), offset + size]
|
548
|
+
rescue StandardError => e
|
549
|
+
raise PacketError, "Caught exception, maybe packet malformed => #{e.message}"
|
550
|
+
end
|
560
551
|
end
|
561
|
-
|
562
552
|
end
|
563
553
|
end
|