net-dns 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +6 -14
  2. data/.gitignore +1 -1
  3. data/.rspec +1 -0
  4. data/.rubocop.yml +3 -0
  5. data/.rubocop_defaults.yml +364 -0
  6. data/.rubocop_todo.yml +207 -0
  7. data/.travis.yml +9 -16
  8. data/CHANGELOG.md +12 -1
  9. data/Gemfile +6 -2
  10. data/LICENSE.txt +56 -0
  11. data/README.md +94 -77
  12. data/Rakefile +23 -56
  13. data/bin/console +14 -0
  14. data/demo/check_soa.rb +27 -38
  15. data/demo/threads.rb +3 -7
  16. data/lib/net/dns.rb +4 -11
  17. data/lib/net/dns/core_ext.rb +8 -15
  18. data/lib/net/dns/header.rb +58 -66
  19. data/lib/net/dns/names.rb +25 -23
  20. data/lib/net/dns/packet.rb +136 -139
  21. data/lib/net/dns/question.rb +36 -39
  22. data/lib/net/dns/resolver.rb +103 -113
  23. data/lib/net/dns/resolver/socks.rb +45 -51
  24. data/lib/net/dns/resolver/timeouts.rb +17 -26
  25. data/lib/net/dns/rr.rb +107 -117
  26. data/lib/net/dns/rr/a.rb +46 -55
  27. data/lib/net/dns/rr/aaaa.rb +40 -49
  28. data/lib/net/dns/rr/classes.rb +26 -29
  29. data/lib/net/dns/rr/cname.rb +33 -41
  30. data/lib/net/dns/rr/hinfo.rb +44 -56
  31. data/lib/net/dns/rr/mr.rb +33 -42
  32. data/lib/net/dns/rr/mx.rb +37 -47
  33. data/lib/net/dns/rr/ns.rb +33 -41
  34. data/lib/net/dns/rr/null.rb +8 -11
  35. data/lib/net/dns/rr/ptr.rb +14 -20
  36. data/lib/net/dns/rr/soa.rb +27 -30
  37. data/lib/net/dns/rr/srv.rb +13 -17
  38. data/lib/net/dns/rr/txt.rb +8 -11
  39. data/lib/net/dns/rr/types.rb +97 -99
  40. data/lib/net/dns/version.rb +5 -13
  41. data/net-dns.gemspec +17 -29
  42. data/{fixtures → spec/fixtures}/resolv.conf +0 -0
  43. data/spec/spec_helper.rb +14 -0
  44. data/spec/unit/resolver/dns_timeout_spec.rb +36 -0
  45. data/spec/unit/resolver/tcp_timeout_spec.rb +46 -0
  46. data/spec/unit/resolver/udp_timeout_spec.rb +46 -0
  47. data/test/test_helper.rb +12 -3
  48. data/test/{header_test.rb → unit/header_test.rb} +43 -46
  49. data/test/{names_test.rb → unit/names_test.rb} +1 -1
  50. data/test/{packet_test.rb → unit/packet_test.rb} +3 -5
  51. data/test/{question_test.rb → unit/question_test.rb} +3 -5
  52. data/test/{resolver_test.rb → unit/resolver_test.rb} +10 -13
  53. data/test/{rr → unit/rr}/a_test.rb +10 -17
  54. data/test/{rr → unit/rr}/aaaa_test.rb +7 -14
  55. data/test/{rr → unit/rr}/classes_test.rb +14 -16
  56. data/test/{rr → unit/rr}/cname_test.rb +7 -14
  57. data/test/{rr → unit/rr}/hinfo_test.rb +16 -22
  58. data/test/{rr → unit/rr}/mr_test.rb +12 -18
  59. data/test/{rr → unit/rr}/mx_test.rb +18 -24
  60. data/test/{rr → unit/rr}/ns_test.rb +10 -16
  61. data/test/{rr → unit/rr}/types_test.rb +10 -8
  62. data/test/{rr_test.rb → unit/rr_test.rb} +33 -37
  63. metadata +77 -49
  64. data/test/resolver/timeouts_test.rb +0 -109
@@ -1,20 +1,13 @@
1
1
  language: ruby
2
2
 
3
3
  rvm:
4
- - 1.8.7
5
- - 1.9.2
6
- - 1.9.3
7
- - 2.0.0
8
- # - jruby-18mode
9
- # - jruby-19mode
10
- - rbx-18mode
11
- # - ruby-head
12
- # - jruby-head
4
+ - 2.1
5
+ - 2.2
6
+ - 2.3
7
+ - 2.4
8
+ - 2.5
9
+ - jruby-9.1.5.0
10
+ - ruby-head
13
11
 
14
- notifications:
15
- recipients:
16
- - weppos@weppos.net
17
-
18
- matrix:
19
- allow_failures:
20
- - rvm: 2.0.0
12
+ cache:
13
+ - bundler
@@ -1,7 +1,18 @@
1
1
  # Changelog
2
2
 
3
3
 
4
- ## master
4
+ ## Release 0.9.0
5
+
6
+ - FIXED: Fixed CI run (GH-77).
7
+
8
+ - FIXED: Fixed deprecated references to Fixnum.
9
+
10
+ - CHANGED: Major code cleanup.
11
+
12
+ - CHANGED: Minimum Ruby version is now 2.1
13
+
14
+
15
+ ## Release 0.8.0
5
16
 
6
17
  - FIXED: undefined local variable or method `source_address_inet6' (GH-40). [Thanks @simsicon]
7
18
 
data/Gemfile CHANGED
@@ -1,4 +1,8 @@
1
- source "http://rubygems.org"
1
+ source "https://rubygems.org"
2
2
 
3
- # Specify your gem's dependencies in whois.gemspec
4
3
  gemspec
4
+
5
+ gem "minitest"
6
+ gem "minitest-reporters"
7
+ gem "rspec"
8
+ gem "rubocop", require: false
@@ -0,0 +1,56 @@
1
+ net-dns is copyrighted free software by Marco Ceresa (@bluemonk) and Simone Carletti (@weppos).
2
+ You can redistribute it and/or modify it under either the terms of the
3
+ 2-clause BSDL (see the file BSDL), or the conditions below:
4
+
5
+ 1. You may make and give away verbatim copies of the source form of the
6
+ software without restriction, provided that you duplicate all of the
7
+ original copyright notices and associated disclaimers.
8
+
9
+ 2. You may modify your copy of the software in any way, provided that
10
+ you do at least ONE of the following:
11
+
12
+ a) place your modifications in the Public Domain or otherwise
13
+ make them Freely Available, such as by posting said
14
+ modifications to Usenet or an equivalent medium, or by allowing
15
+ the author to include your modifications in the software.
16
+
17
+ b) use the modified software only within your corporation or
18
+ organization.
19
+
20
+ c) give non-standard binaries non-standard names, with
21
+ instructions on where to get the original software distribution.
22
+
23
+ d) make other distribution arrangements with the author.
24
+
25
+ 3. You may distribute the software in object code or binary form,
26
+ provided that you do at least ONE of the following:
27
+
28
+ a) distribute the binaries and library files of the software,
29
+ together with instructions (in the manual page or equivalent)
30
+ on where to get the original distribution.
31
+
32
+ b) accompany the distribution with the machine-readable source of
33
+ the software.
34
+
35
+ c) give non-standard binaries non-standard names, with
36
+ instructions on where to get the original software distribution.
37
+
38
+ d) make other distribution arrangements with the author.
39
+
40
+ 4. You may modify and include the part of the software into any other
41
+ software (possibly commercial). But some files in the distribution
42
+ are not written by the author, so that they are not under these terms.
43
+
44
+ For the list of those files and their copying conditions, see the
45
+ file LEGAL.
46
+
47
+ 5. The scripts and library files supplied as input to or produced as
48
+ output from the software do not automatically fall under the
49
+ copyright of the software, but belong to whomever generated them,
50
+ and may be sold commercially, and may be aggregated with this
51
+ software.
52
+
53
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
54
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
55
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
56
+ PURPOSE.
data/README.md CHANGED
@@ -12,16 +12,16 @@ Net::DNS is a DNS library written in pure Ruby. It started as a port of Perl Net
12
12
 
13
13
  ## Requirements
14
14
 
15
- * Ruby >= 1.8.7
15
+ Ruby >= 2.1
16
16
 
17
17
 
18
18
  ## Installation
19
19
 
20
20
  The best way to install this library is via [RubyGems](https://rubygems.org/).
21
21
 
22
- $ gem install net-dns
23
-
24
- You might need administrator privileges on your system to install the gem.
22
+ ```
23
+ gem install net-dns
24
+ ```
25
25
 
26
26
 
27
27
  ## API Documentation
@@ -33,71 +33,80 @@ Visit the page http://rdoc.info/gems/net-dns
33
33
 
34
34
  The simplest way to use the library is to invoke the Resolver() method:
35
35
 
36
- require 'rubygems'
37
- require 'net/dns'
38
- p Resolver("www.google.com")
36
+ ```ruby
37
+ require 'rubygems'
38
+ require 'net/dns'
39
+ p Resolver("www.google.com")
40
+ ```
39
41
 
40
42
  The output is compatible with BIND zone files and it's the same you would get with the dig utility.
41
43
 
42
- ;; Answer received from localhost:53 (212 bytes)
43
- ;;
44
- ;; HEADER SECTION
45
- ;; id = 64075
46
- ;; qr = 1 opCode: QUERY aa = 0 tc = 0 rd = 1
47
- ;; ra = 1 ad = 0 cd = 0 rcode = NoError
48
- ;; qdCount = 1 anCount = 3 nsCount = 4 arCount = 4
49
-
50
- ;; QUESTION SECTION (1 record):
51
- ;; google.com. IN A
52
-
53
- ;; ANSWER SECTION (3 records):
54
- google.com. 212 IN A 74.125.45.100
55
- google.com. 212 IN A 74.125.67.100
56
- google.com. 212 IN A 209.85.171.100
57
-
58
- ;; AUTHORITY SECTION (4 records):
59
- google.com. 345512 IN NS ns1.google.com.
60
- google.com. 345512 IN NS ns4.google.com.
61
- google.com. 345512 IN NS ns2.google.com.
62
- google.com. 345512 IN NS ns3.google.com.
63
-
64
- ;; ADDITIONAL SECTION (4 records):
65
- ns1.google.com. 170275 IN A 216.239.32.10
66
- ns2.google.com. 170275 IN A 216.239.34.10
67
- ns3.google.com. 170275 IN A 216.239.36.10
68
- ns4.google.com. 170275 IN A 216.239.38.10
44
+ ```
45
+ ;; Answer received from localhost:53 (212 bytes)
46
+ ;;
47
+ ;; HEADER SECTION
48
+ ;; id = 64075
49
+ ;; qr = 1 opCode: QUERY aa = 0 tc = 0 rd = 1
50
+ ;; ra = 1 ad = 0 cd = 0 rcode = NoError
51
+ ;; qdCount = 1 anCount = 3 nsCount = 4 arCount = 4
52
+
53
+ ;; QUESTION SECTION (1 record):
54
+ ;; google.com. IN A
55
+
56
+ ;; ANSWER SECTION (3 records):
57
+ google.com. 212 IN A 74.125.45.100
58
+ google.com. 212 IN A 74.125.67.100
59
+ google.com. 212 IN A 209.85.171.100
60
+
61
+ ;; AUTHORITY SECTION (4 records):
62
+ google.com. 345512 IN NS ns1.google.com.
63
+ google.com. 345512 IN NS ns4.google.com.
64
+ google.com. 345512 IN NS ns2.google.com.
65
+ google.com. 345512 IN NS ns3.google.com.
66
+
67
+ ;; ADDITIONAL SECTION (4 records):
68
+ ns1.google.com. 170275 IN A 216.239.32.10
69
+ ns2.google.com. 170275 IN A 216.239.34.10
70
+ ns3.google.com. 170275 IN A 216.239.36.10
71
+ ns4.google.com. 170275 IN A 216.239.38.10
72
+ ```
69
73
 
70
74
  An optional block can be passed yielding the Net::DNS::Packet object
71
75
 
72
- Resolver("www.google.com") { |packet| puts packet.size + " bytes" }
73
- # => 484 bytes
76
+ ```ruby
77
+ Resolver("www.google.com") { |packet| puts packet.size + " bytes" }
78
+ # => 484 bytes
79
+ ```
74
80
 
75
81
  Same for Net::DNS::Resolver.start():
76
82
 
77
- Net::DNS::Resolver.start("google.com").answer.size
78
- # => 5
83
+ ```ruby
84
+ Net::DNS::Resolver.start("google.com").answer.size
85
+ # => 5
86
+ ```
79
87
 
80
88
  As optional parameters, +TYPE+ and +CLASS+ can be specified.
81
89
 
82
- p Net::DNS::Resolver.start("google.com", Net::DNS::MX)
83
-
84
- ;; Answer received from localhost:53 (316 bytes)
85
- ;;
86
- ;; HEADER SECTION
87
- ;; id = 59980
88
- ;; qr = 1 opCode: QUERY aa = 0 tc = 0 rd = 1
89
- ;; ra = 1 ad = 0 cd = 0 rcode = NoError
90
- ;; qdCount = 1 anCount = 4 nsCount = 4 arCount = 8
91
-
92
- ;; QUESTION SECTION (1 record):
93
- ;; google.com. IN MX
94
-
95
- ;; ANSWER SECTION (4 records):
96
- google.com. 10800 IN MX 10 smtp2.google.com.
97
- google.com. 10800 IN MX 10 smtp3.google.com.
98
- google.com. 10800 IN MX 10 smtp4.google.com.
99
- google.com. 10800 IN MX 10 smtp1.google.com.
90
+ ```ruby
91
+ p Net::DNS::Resolver.start("google.com", Net::DNS::MX)
92
+
93
+ ;; Answer received from localhost:53 (316 bytes)
94
+ ;;
95
+ ;; HEADER SECTION
96
+ ;; id = 59980
97
+ ;; qr = 1 opCode: QUERY aa = 0 tc = 0 rd = 1
98
+ ;; ra = 1 ad = 0 cd = 0 rcode = NoError
99
+ ;; qdCount = 1 anCount = 4 nsCount = 4 arCount = 8
100
100
 
101
+ ;; QUESTION SECTION (1 record):
102
+ ;; google.com. IN MX
103
+
104
+ ;; ANSWER SECTION (4 records):
105
+ google.com. 10800 IN MX 10 smtp2.google.com.
106
+ google.com. 10800 IN MX 10 smtp3.google.com.
107
+ google.com. 10800 IN MX 10 smtp4.google.com.
108
+ google.com. 10800 IN MX 10 smtp1.google.com.
109
+ ```
101
110
 
102
111
  ## Handling the response packet
103
112
 
@@ -113,35 +122,43 @@ A DNS packet is divided into 5 sections:
113
122
 
114
123
  You can access each section by calling the attribute with the same name on a Packet object:
115
124
 
116
- packet = Net::DNS::Resolver.start("google.com")
117
-
118
- header = packet.header
119
- answer = packet.answer
120
-
121
- puts "The packet is #{packet.data.size} bytes"
122
- puts "It contains #{header.anCount} answer entries"
123
-
124
- answer.any? {|ans| p ans}
125
-
125
+ ```ruby
126
+ packet = Net::DNS::Resolver.start("google.com")
127
+
128
+ header = packet.header
129
+ answer = packet.answer
130
+
131
+ puts "The packet is #{packet.data.size} bytes"
132
+ puts "It contains #{header.anCount} answer entries"
133
+
134
+ answer.any? {|ans| p ans}
135
+ ```
136
+
126
137
  The output is
127
138
 
128
- The packet is 378 bytes
129
- It contains 3 answer entries
130
- google.com. 244 IN A 74.125.45.100
131
- google.com. 244 IN A 74.125.67.100
132
- google.com. 244 IN A 209.85.171.100
139
+ ```
140
+ The packet is 378 bytes
141
+ It contains 3 answer entries
142
+ google.com. 244 IN A 74.125.45.100
143
+ google.com. 244 IN A 74.125.67.100
144
+ google.com. 244 IN A 209.85.171.100
145
+ ```
133
146
 
134
147
  A better way to handle the answer section is to use the iterators directly on a Packet object:
135
148
 
136
- packet.each_address do |ip|
137
- puts "#{ip} is alive" if Ping.pingecho(ip.to_s, 10, 80)
138
- end
149
+ ```ruby
150
+ packet.each_address do |ip|
151
+ puts "#{ip} is alive" if Ping.pingecho(ip.to_s, 10, 80)
152
+ end
153
+ ```
139
154
 
140
155
  Gives:
141
156
 
142
- 74.125.45.100 is alive
143
- 74.125.67.100 is alive
144
- 209.85.171.100 is alive
157
+ ```
158
+ 74.125.45.100 is alive
159
+ 74.125.67.100 is alive
160
+ 209.85.171.100 is alive
161
+ ```
145
162
 
146
163
 
147
164
  ## License
data/Rakefile CHANGED
@@ -1,71 +1,38 @@
1
- require 'rubygems'
2
- require 'bundler'
3
-
4
- $:.unshift(File.dirname(__FILE__) + "/lib")
5
- require 'net/dns'
6
-
7
-
8
- # Common package properties
9
- PKG_NAME = ENV['PKG_NAME'] || 'net-dns'
10
- PKG_VERSION = ENV['PKG_VERSION'] || Net::DNS::VERSION
11
-
1
+ require "bundler/gem_tasks"
12
2
 
13
3
  # Run test by default.
14
- task :default => :test
15
-
4
+ task default: :test
5
+ task test: %i[testunit spec]
16
6
 
17
- spec = Gem::Specification.new do |s|
18
- s.name = PKG_NAME
19
- s.version = PKG_VERSION
20
- s.summary = "Pure Ruby DNS library."
21
- s.description = "Net::DNS is a pure Ruby DNS library, with a clean OO interface and an extensible API."
22
-
23
- s.required_ruby_version = ">= 1.8.7"
24
-
25
- s.authors = ["Marco Ceresa", "Simone Carletti"]
26
- s.email = ["ceresa@gmail.com", "weppos@weppos.net"]
27
- s.homepage = "http://github.com/bluemonk/net-dns"
28
- s.rubyforge_project = "net-dns"
29
-
30
- s.add_development_dependency "rake", "~> 10.0"
31
- s.add_development_dependency "yard"
7
+ require 'rake/testtask'
32
8
 
33
- s.files = `git ls-files`.split("\n")
34
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
35
- s.require_paths = %w( lib )
9
+ Rake::TestTask.new(:testunit) do |t|
10
+ t.libs = %w[lib test]
11
+ t.pattern = "test/**/*_test.rb"
12
+ t.verbose = !ENV["VERBOSE"].nil?
13
+ t.warning = !ENV["WARNING"].nil?
36
14
  end
37
15
 
16
+ require "rubocop/rake_task"
38
17
 
39
- require 'rubygems/package_task'
18
+ RuboCop::RakeTask.new
40
19
 
41
- Gem::PackageTask.new(spec) do |pkg|
42
- pkg.gem_spec = spec
20
+ require 'rspec/core/rake_task'
21
+ begin
22
+ require 'fuubar'
23
+ rescue LoadError
43
24
  end
44
25
 
45
- desc "Build the gemspec file #{spec.name}.gemspec"
46
- task :gemspec do
47
- file = File.dirname(__FILE__) + "/#{spec.name}.gemspec"
48
- File.open(file, "w") {|f| f << spec.to_ruby }
26
+ RSpec::Core::RakeTask.new do |t|
27
+ t.verbose = !!ENV["VERBOSE"]
28
+ t.rspec_opts = []
29
+ t.rspec_opts << ['--format', 'Fuubar'] if defined?(Fuubar)
49
30
  end
50
31
 
51
-
52
- require 'rake/testtask'
53
-
54
- # Run all the tests in the /test folder
55
- Rake::TestTask.new do |t|
56
- t.libs << "test"
57
- t.test_files = FileList["test/**/*_test.rb"]
58
- t.verbose = true
59
- end
60
-
61
-
62
- require 'yard'
63
32
  require 'yard/rake/yardoc_task'
64
33
 
65
- YARD::Rake::YardocTask.new(:yardoc)
66
-
67
-
68
- desc "Open an irb session preloaded with this library"
69
- task :console do
70
- sh "irb -rubygems -I lib -r net/dns.rb"
34
+ YARD::Rake::YardocTask.new(:yardoc) do |y|
35
+ y.options = ["--output-dir", "yardoc"]
71
36
  end
37
+
38
+ CLOBBER.include "yardoc"
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "net/dns"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -1,9 +1,8 @@
1
- #!/usr/bin/env ruby
1
+ #!/usr/bin/env ruby
2
2
 
3
- require 'rubygems' if "#{RUBY_VERSION}" < "1.9.0"
3
+ require 'rubygems' if RUBY_VERSION.to_s < "1.9.0"
4
4
  require 'net/dns'
5
5
 
6
-
7
6
  #------------------------------------------------------------------------------
8
7
  # Get the domain from the command line.
9
8
  #------------------------------------------------------------------------------
@@ -16,100 +15,90 @@ domain = ARGV[0]
16
15
  # Find all the nameservers for the domain.
17
16
  #------------------------------------------------------------------------------
18
17
 
19
- res = Net::DNS::Resolver.new(:defname => false, :retry => 2)
18
+ res = Net::DNS::Resolver.new(defname: false, retry: 2)
20
19
 
21
20
  ns_req = res.query(domain, Net::DNS::NS)
22
- unless ns_req and ns_req.header.anCount > 0
21
+ unless ns_req && (ns_req.header.anCount > 0)
23
22
  raise ArgumentError, "No nameservers found for domain: #{res.errorstring}"
24
23
  end
25
24
 
26
-
27
25
  # Send out non-recursive queries
28
26
  res.recurse = false
29
27
  # Do not buffer standard out
30
- #| = 1;
31
-
28
+ # | = 1;
32
29
 
33
30
  #------------------------------------------------------------------------------
34
31
  # Check the SOA record on each nameserver.
35
32
  #------------------------------------------------------------------------------
36
33
 
37
34
  ns_req.each_nameserver do |ns|
38
-
39
35
  #----------------------------------------------------------------------
40
36
  # Set the resolver to query this nameserver.
41
37
  #----------------------------------------------------------------------
42
-
38
+
43
39
  # In order to lookup the IP(s) of the nameserver, we need a Resolver
44
40
  # object that is set to our local, recursive nameserver. So we create
45
41
  # a new object just to do that.
46
-
42
+
47
43
  local_res = Net::DNS::Resolver.new
48
-
44
+
49
45
  a_req = local_res.query(ns, Net::DNS::A)
50
-
51
-
52
- unless a_req
46
+
47
+ unless a_req
53
48
  puts "Can not find address for ns: " + res.errorstring + "\n"
54
49
  next
55
50
  end
56
-
57
-
58
- a_req.each_address do |ip|
59
51
 
52
+ a_req.each_address do |ip|
60
53
  #----------------------------------------------------------------------
61
54
  # Ask this IP.
62
55
  #----------------------------------------------------------------------
63
- res.nameservers=ip
64
-
56
+ res.nameservers = ip
57
+
65
58
  print "#{ns} (#{ip}): "
66
-
59
+
67
60
  #----------------------------------------------------------------------
68
61
  # Get the SOA record.
69
62
  #----------------------------------------------------------------------
70
-
63
+
71
64
  soa_req = res.send(domain, Net::DNS::SOA, Net::DNS::IN)
72
-
73
- if soa_req == nil
65
+
66
+ if soa_req.nil?
74
67
  puts res.errorstring, "\n"
75
68
  next
76
69
  end
77
-
70
+
78
71
  #----------------------------------------------------------------------
79
72
  # Is this nameserver authoritative for the domain?
80
73
  #----------------------------------------------------------------------
81
-
82
- unless soa_req.header.auth?
74
+
75
+ unless soa_req.header.auth?
83
76
  print "isn't authoritative for domain\n"
84
77
  next
85
78
  end
86
-
79
+
87
80
  #----------------------------------------------------------------------
88
81
  # We should have received exactly one answer.
89
82
  #----------------------------------------------------------------------
90
-
91
- unless soa_req.header.anCount == 1
83
+
84
+ unless soa_req.header.anCount == 1
92
85
  print "expected 1 answer, got " + soa_req.header.anCount.to_s + "\n"
93
86
  next
94
87
  end
95
-
88
+
96
89
  #----------------------------------------------------------------------
97
90
  # Did we receive an SOA record?
98
91
  #----------------------------------------------------------------------
99
-
92
+
100
93
  unless soa_req.answer[0].class == Net::DNS::RR::SOA
101
94
  print "expected SOA, got " + Net::DNS::RR::RRTypes.to_str(soa_req.answer[0].type) + "\n"
102
95
  next
103
96
  end
104
-
97
+
105
98
  #----------------------------------------------------------------------
106
99
  # Print the serial number.
107
100
  #----------------------------------------------------------------------
108
-
101
+
109
102
  print "has serial number " + soa_req.answer[0].serial.to_s + "\n"
110
-
111
103
  end
112
104
  end
113
-
114
-
115
-