net-dns 0.5.3 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/AUTHORS.rdoc +7 -0
- data/CHANGELOG.rdoc +34 -0
- data/README.rdoc +26 -14
- data/Rakefile +23 -30
- data/{THANKS → THANKS.rdoc} +0 -0
- data/VERSION.yml +3 -2
- data/demo/check_soa.rb +6 -11
- data/lib/net/{dns/dns.rb → dns.rb} +5 -12
- data/lib/net/dns/core_ext.rb +52 -0
- data/lib/net/dns/header.rb +55 -49
- data/lib/net/dns/names/names.rb +20 -10
- data/lib/net/dns/packet.rb +33 -26
- data/lib/net/dns/question.rb +60 -27
- data/lib/net/dns/resolver.rb +101 -156
- data/lib/net/dns/resolver/timeouts.rb +71 -65
- data/lib/net/dns/rr.rb +131 -166
- data/lib/net/dns/rr/a.rb +20 -26
- data/lib/net/dns/rr/aaaa.rb +15 -20
- data/lib/net/dns/rr/classes.rb +1 -1
- data/lib/net/dns/rr/cname.rb +8 -14
- data/lib/net/dns/rr/hinfo.rb +8 -14
- data/lib/net/dns/rr/mr.rb +8 -14
- data/lib/net/dns/rr/mx.rb +11 -18
- data/lib/net/dns/rr/ns.rb +8 -14
- data/lib/net/dns/rr/null.rb +7 -14
- data/lib/net/dns/rr/ptr.rb +9 -15
- data/lib/net/dns/rr/soa.rb +9 -15
- data/lib/net/dns/rr/srv.rb +10 -19
- data/lib/net/dns/rr/txt.rb +9 -20
- data/lib/net/dns/rr/types.rb +51 -58
- data/lib/net/dns/version.rb +22 -0
- data/test/{net/dns/test_header.rb → header_test.rb} +20 -20
- data/test/{net/dns/test_packet.rb → packet_test.rb} +2 -2
- data/test/question_test.rb +84 -0
- data/test/resolver/timeouts_test.rb +109 -0
- data/test/{net/dns/test_resolver.rb → resolver_test.rb} +6 -6
- data/test/rr/a_test.rb +66 -0
- data/test/{net/dns/rr/test_classes.rb → rr/classes_test.rb} +5 -5
- data/test/rr/ns_test.rb +64 -0
- data/test/rr/types_test.rb +69 -0
- data/test/{net/dns/test_rr.rb → rr_test.rb} +10 -12
- data/test/test_helper.rb +4 -0
- metadata +50 -35
- data/AUTHORS +0 -10
- data/CHANGELOG +0 -7
- data/INSTALL +0 -8
- data/net-dns.gemspec +0 -92
- data/test/net/dns/resolver/test_timeouts.rb +0 -59
- data/test/net/dns/rr/test_a.rb +0 -72
- data/test/net/dns/rr/test_ns.rb +0 -66
- data/test/net/dns/rr/test_types.rb +0 -124
- data/test/net/dns/test_question.rb +0 -54
data/.gitignore
ADDED
data/AUTHORS.rdoc
ADDED
data/CHANGELOG.rdoc
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
= Changelog
|
2
|
+
|
3
|
+
== Release 0.6.0
|
4
|
+
|
5
|
+
*WARNING:* If you are upgrading from a previous minor release, check out the Compatibility issue list below.
|
6
|
+
|
7
|
+
* FIXED: Added missing #to_s method to Net::DNS::Question.
|
8
|
+
|
9
|
+
* FIXED: Compatibility with Ruby 1.9
|
10
|
+
|
11
|
+
* FIXED: Types regexp order issue
|
12
|
+
|
13
|
+
* CHANGED: Refactoring unit test to follow most used Ruby conventions
|
14
|
+
|
15
|
+
* CHANGED: default timeout is now 5 seconds for both UDP and TCP
|
16
|
+
|
17
|
+
* CHANGED: Moved main dns.rb file to lib/net folder as default for GEMs. In this way it can be autoloaded when the gem is required.
|
18
|
+
|
19
|
+
=== Compatibility issues
|
20
|
+
|
21
|
+
* CHANGED: RR#set_stype scope is now private to prevent invalid usage.
|
22
|
+
|
23
|
+
* CHANGED: DnsTimeout#timeout now raises LocalJumpError instead of DnsTimeoutArgumentError when block is missing.
|
24
|
+
|
25
|
+
* CHANGED: Renamed Net::DNS::RR::Types::Types to Net::DNS::RR::Types::TYPES to follow Ruby coding standards.
|
26
|
+
|
27
|
+
|
28
|
+
== Release 0.4
|
29
|
+
|
30
|
+
* many bug fixes (thanks guys!)
|
31
|
+
* a whole new class Net::DNS::Header::RCode
|
32
|
+
* new methods in Net::DNS::Resolver class to do AXFR queries
|
33
|
+
* a new SRV resource record written by Dan Janowski
|
34
|
+
* more documentation written and corrected
|
data/README.rdoc
CHANGED
@@ -2,34 +2,46 @@
|
|
2
2
|
|
3
3
|
Net::DNS is a DNS library written in pure Ruby. It started as a port of Perl Net::DNS module, but it evolved in time into a full Ruby library.
|
4
4
|
|
5
|
-
Features:
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
== Features
|
7
|
+
|
8
|
+
* Complete OO interface
|
9
|
+
* Clean and intuitive API
|
10
|
+
* Modular and flexible
|
11
|
+
|
12
|
+
|
13
|
+
== Requirements
|
14
|
+
|
15
|
+
* Ruby >= 1.8.6 (not tested with previous versions)
|
16
|
+
|
17
|
+
As of release TODO, Net::DNS is compatible with Ruby 1.9.1.
|
18
|
+
|
10
19
|
|
11
20
|
== Install
|
12
21
|
|
13
|
-
Just use
|
14
|
-
|
15
|
-
|
22
|
+
Just use RubyGems:
|
23
|
+
|
24
|
+
$ gem install net-dns
|
16
25
|
|
17
26
|
If you want to install from source, you can use Rake:
|
18
|
-
|
19
|
-
$ rake install
|
20
27
|
|
21
|
-
|
28
|
+
$ rake install
|
29
|
+
|
30
|
+
Or directly from setup.rb
|
31
|
+
|
32
|
+
$ ruby setup.rb
|
22
33
|
|
23
|
-
$ sudo ruby install.rb
|
24
34
|
|
25
35
|
== API Documentation
|
26
36
|
|
27
37
|
Visit the page http://marcoceresa.com/net-dns
|
28
38
|
|
39
|
+
|
29
40
|
== Trivial resolver
|
30
41
|
|
31
42
|
The simplest way to use the library is to invoke the Resolver() method:
|
32
43
|
|
44
|
+
require 'rubygems'
|
33
45
|
require 'net/dns/resolver'
|
34
46
|
p Resolver("www.google.com")
|
35
47
|
|
@@ -74,7 +86,7 @@ Same for Net::DNS::Resolver.start():
|
|
74
86
|
Net::DNS::Resolver.start("google.com").answer.size
|
75
87
|
#=> 5
|
76
88
|
|
77
|
-
As
|
89
|
+
As optional parameters, +TYPE+ and +CLASS+ can be specified.
|
78
90
|
|
79
91
|
p Net::DNS::Resolver.start("google.com", Net::DNS::MX)
|
80
92
|
|
@@ -144,7 +156,7 @@ Gives:
|
|
144
156
|
|
145
157
|
Net::DNS is distributed under the same license Ruby is.
|
146
158
|
|
159
|
+
|
147
160
|
== Author
|
148
161
|
|
149
|
-
(c) Marco Ceresa 2006
|
150
|
-
|
162
|
+
(c) Marco Ceresa 2006-2009
|
data/Rakefile
CHANGED
@@ -1,25 +1,21 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'rake'
|
3
|
-
|
4
|
-
#
|
5
|
-
# Gem specifications
|
6
|
-
#
|
7
|
-
SPEC = Gem::Specification.new do |s|
|
8
|
-
s.name = "net-dns"
|
9
|
-
s.authors = ["Marco Ceresa"]
|
10
|
-
s.email = "ceresa@gmail.com"
|
11
|
-
s.homepage = "http://github.com/bluemonk/net-dns"
|
12
|
-
s.platform = Gem::Platform::RUBY
|
13
|
-
s.summary = "Pure Ruby DNS library"
|
14
|
-
s.has_rdoc = true
|
15
|
-
s.extra_rdoc_files = ["README.rdoc","AUTHORS","INSTALL", "THANKS"]
|
16
|
-
s.description = "Net::DNS is a pure Ruby DNS library, with a clean OO interface and an extensible API"
|
17
|
-
s.rubyforge_project = "net-dns"
|
18
|
-
end
|
3
|
+
require 'rake/clean'
|
19
4
|
|
20
5
|
begin
|
21
6
|
require 'jeweler'
|
22
|
-
Jeweler::Tasks.new
|
7
|
+
Jeweler::Tasks.new do |gemspec|
|
8
|
+
gemspec.name = "net-dns"
|
9
|
+
gemspec.summary = "Pure Ruby DNS library"
|
10
|
+
gemspec.description = "Net::DNS is a pure Ruby DNS library, with a clean OO interface and an extensible API"
|
11
|
+
gemspec.authors = ["Marco Ceresa", "Simone Carletti"]
|
12
|
+
gemspec.email = ["ceresa@gmail.com", "weppos@weppos.net"]
|
13
|
+
gemspec.homepage = "http://github.com/bluemonk/net-dns"
|
14
|
+
gemspec.extra_rdoc_files = ["README.rdoc", "CHANGELOG.rdoc", "AUTHORS.rdoc", "THANKS.rdoc"]
|
15
|
+
gemspec.rubyforge_project = "net-dns"
|
16
|
+
|
17
|
+
gemspec.add_development_dependency "rcov"
|
18
|
+
end
|
23
19
|
Jeweler::RubyforgeTasks.new
|
24
20
|
rescue LoadError
|
25
21
|
puts "Jeweler not available."
|
@@ -27,8 +23,7 @@ end
|
|
27
23
|
|
28
24
|
require 'rake/testtask'
|
29
25
|
Rake::TestTask.new(:test) do |test|
|
30
|
-
|
31
|
-
test.libs << 'lib' << 'test'
|
26
|
+
test.libs << 'test'
|
32
27
|
test.pattern = 'test/**/*_test.rb'
|
33
28
|
test.verbose = true
|
34
29
|
end
|
@@ -36,14 +31,12 @@ end
|
|
36
31
|
begin
|
37
32
|
require 'rcov/rcovtask'
|
38
33
|
Rcov::RcovTask.new(:rcov) do |test|
|
39
|
-
test.libs
|
34
|
+
test.libs << 'test'
|
40
35
|
test.pattern = 'test/**/*_test.rb'
|
41
36
|
test.verbose = true
|
42
37
|
end
|
43
38
|
rescue LoadError
|
44
|
-
task :rcov
|
45
|
-
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
46
|
-
end
|
39
|
+
task :rcov => :check_dependencies
|
47
40
|
end
|
48
41
|
|
49
42
|
task :default => :test
|
@@ -51,16 +44,16 @@ task :default => :test
|
|
51
44
|
require 'rake/rdoctask'
|
52
45
|
Rake::RDocTask.new do |rdoc|
|
53
46
|
if File.exist?('VERSION.yml')
|
54
|
-
config
|
47
|
+
config = YAML.load(File.read('VERSION.yml'))
|
55
48
|
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
56
49
|
else
|
57
|
-
puts "
|
50
|
+
puts "VERSION.yml not found!"
|
58
51
|
version = ""
|
59
52
|
end
|
60
53
|
|
61
54
|
rdoc.rdoc_dir = 'rdoc'
|
62
55
|
rdoc.title = "net-dns #{version}"
|
63
|
-
rdoc.rdoc_files.include('
|
56
|
+
rdoc.rdoc_files.include('*.rdoc')
|
64
57
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
65
58
|
end
|
66
59
|
|
@@ -109,7 +102,7 @@ task :todo do
|
|
109
102
|
egrep /(FIXME|TODO|TBD)/
|
110
103
|
end
|
111
104
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
105
|
+
desc "Open an irb session preloaded with this library"
|
106
|
+
task :console do
|
107
|
+
sh "irb -rubygems -I lib -r net/dns.rb"
|
108
|
+
end
|
data/{THANKS → THANKS.rdoc}
RENAMED
File without changes
|
data/VERSION.yml
CHANGED
data/demo/check_soa.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
# $Id: check_soa.rb,v 1.7 2006/07/30 16:53:57 bluemonk Exp $
|
4
|
-
|
5
|
-
|
6
3
|
require 'rubygems' if "#{RUBY_VERSION}" < "1.9.0"
|
7
4
|
require 'net/dns/resolver'
|
8
5
|
|
6
|
+
|
9
7
|
#------------------------------------------------------------------------------
|
10
8
|
# Get the domain from the command line.
|
11
9
|
#------------------------------------------------------------------------------
|
@@ -20,17 +18,14 @@ domain = ARGV[0]
|
|
20
18
|
|
21
19
|
res = Net::DNS::Resolver.new(:defname => false, :retry => 2)
|
22
20
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
ns_req = res.query(domain, Net::DNS::NS);
|
28
|
-
raise ArgumentError, "No nameservers found for domain: " + res.errorstring +
|
29
|
-
"\n" unless ns_req and ns_req.header.anCount > 0
|
21
|
+
ns_req = res.query(domain, Net::DNS::NS)
|
22
|
+
unless ns_req and ns_req.header.anCount > 0
|
23
|
+
raise ArgumentError, "No nameservers found for domain: #{res.errorstring}"
|
24
|
+
end
|
30
25
|
|
31
26
|
|
32
27
|
# Send out non-recursive queries
|
33
|
-
res.recurse=false
|
28
|
+
res.recurse = false
|
34
29
|
# Do not buffer standard out
|
35
30
|
#| = 1;
|
36
31
|
|
@@ -1,16 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
# dns.rb
|
4
|
-
#
|
5
|
-
# $id$
|
6
|
-
#
|
7
|
-
##
|
1
|
+
require 'net/dns/core_ext'
|
2
|
+
require 'net/dns/version'
|
8
3
|
|
9
4
|
module Net # :nodoc:
|
10
5
|
module DNS
|
11
|
-
|
12
|
-
# Version of the library
|
13
|
-
VERSION = "0.4"
|
14
6
|
|
15
7
|
# Packet size in bytes
|
16
8
|
PACKETSZ = 512
|
@@ -30,6 +22,7 @@ module Net # :nodoc:
|
|
30
22
|
# Size of a short int
|
31
23
|
INT16SZ = 2
|
32
24
|
|
25
|
+
|
33
26
|
module QueryTypes
|
34
27
|
|
35
28
|
SIGZERO = 0
|
@@ -113,5 +106,5 @@ module Net # :nodoc:
|
|
113
106
|
include QueryTypes
|
114
107
|
include QueryClasses
|
115
108
|
|
116
|
-
end
|
117
|
-
end
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Net # :nodoc:
|
2
|
+
module DNS
|
3
|
+
|
4
|
+
module HashKeys # :nodoc:
|
5
|
+
|
6
|
+
# Returns an hash with all the
|
7
|
+
# keys turned into downcase
|
8
|
+
#
|
9
|
+
# hsh = {"Test" => 1, "FooBar" => 2}
|
10
|
+
# hsh.downcase_keys!
|
11
|
+
# #=> {"test"=>1,"foobar"=>2}
|
12
|
+
#
|
13
|
+
def downcase_keys!
|
14
|
+
hsh = Hash.new
|
15
|
+
self.each do |key,val|
|
16
|
+
hsh[key.downcase] = val
|
17
|
+
end
|
18
|
+
self.replace(hsh)
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
module HashOperators # :nodoc:
|
24
|
+
|
25
|
+
# Performs a sort of group difference
|
26
|
+
# operation on hashes or arrays
|
27
|
+
#
|
28
|
+
# a = {:a=>1,:b=>2,:c=>3}
|
29
|
+
# b = {:a=>1,:b=>2}
|
30
|
+
# c = [:a,:c]
|
31
|
+
# a-b #=> {:c=>3}
|
32
|
+
# a-c #=> {:b=>2}
|
33
|
+
#
|
34
|
+
def -(other)
|
35
|
+
case other
|
36
|
+
when Hash
|
37
|
+
delete_if { |k,v| other.has_key?(k) }
|
38
|
+
when Array
|
39
|
+
delete_if { |k,v| other.include?(k) }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
class Hash # :nodoc:
|
50
|
+
include Net::DNS::HashKeys
|
51
|
+
include Net::DNS::HashOperators
|
52
|
+
end
|
data/lib/net/dns/header.rb
CHANGED
@@ -1,8 +1,5 @@
|
|
1
|
-
|
2
|
-
# $Id: Header.rb,v 1.5 2006/07/30 16:54:28 bluemonk Exp $
|
3
|
-
#+++
|
1
|
+
require 'net/dns'
|
4
2
|
|
5
|
-
require 'net/dns/dns'
|
6
3
|
|
7
4
|
module Net # :nodoc:
|
8
5
|
module DNS
|
@@ -57,11 +54,11 @@ module Net # :nodoc:
|
|
57
54
|
# which are listed here to keep a light and browsable main documentation.
|
58
55
|
# We have:
|
59
56
|
#
|
60
|
-
#
|
61
|
-
#
|
62
|
-
#
|
63
|
-
#
|
64
|
-
#
|
57
|
+
# ArgumentError:: Argument Error for class Net::DNS::Packet
|
58
|
+
# WrongCountError:: A wrong +count+ parameter has been passed
|
59
|
+
# WrongRecursiveError:: A wrong +recursive+ parameter has been passed
|
60
|
+
# WrongOpcodeError:: A not valid +opCode+ has been specified
|
61
|
+
# DuplicateIDError:: The requested ID is already in use
|
65
62
|
#
|
66
63
|
# =Copyright
|
67
64
|
#
|
@@ -71,9 +68,34 @@ module Net # :nodoc:
|
|
71
68
|
# it and/or modify it under the same terms as Ruby itself.
|
72
69
|
#
|
73
70
|
class Header
|
74
|
-
|
71
|
+
|
72
|
+
# Argument Error for class Net::DNS::Header.
|
73
|
+
class ArgumentError < ArgumentError
|
74
|
+
end
|
75
|
+
|
76
|
+
# A wrong +count+ parameter has been passed-
|
77
|
+
class WrongCountError < ArgumentError
|
78
|
+
end
|
79
|
+
|
80
|
+
# A wrong +recursive+ parameter has been passed-
|
81
|
+
class WrongRecursiveError < ArgumentError
|
82
|
+
end
|
83
|
+
|
84
|
+
# An invalid +opCode+ has been specified.
|
85
|
+
class WrongOpcodeError < ArgumentError
|
86
|
+
end
|
87
|
+
|
88
|
+
# Base error class.
|
89
|
+
class Error < StandardError
|
90
|
+
end
|
91
|
+
|
92
|
+
# The requested ID is already in use.
|
93
|
+
class DuplicateIDError < Error
|
94
|
+
end
|
95
|
+
|
96
|
+
|
75
97
|
#
|
76
|
-
# =Name
|
98
|
+
# = Name
|
77
99
|
#
|
78
100
|
# Net::DNS::Header::RCode - DNS Header RCode handling class
|
79
101
|
#
|
@@ -100,7 +122,7 @@ module Net # :nodoc:
|
|
100
122
|
# problem with the name server.
|
101
123
|
# * 3 Name Error - Meaningful only for
|
102
124
|
# responses from an authoritative name
|
103
|
-
# server, this code
|
125
|
+
# server, this code means that the
|
104
126
|
# domain name referenced in the query does
|
105
127
|
# not exist.
|
106
128
|
# * 4 Not Implemented - The name server does
|
@@ -166,7 +188,7 @@ module Net # :nodoc:
|
|
166
188
|
@type = RCodeType[code]
|
167
189
|
@explanation = RCodeErrorString[code]
|
168
190
|
else
|
169
|
-
raise
|
191
|
+
raise ArgumentError, "RCode `#{code}' out of range"
|
170
192
|
end
|
171
193
|
end
|
172
194
|
|
@@ -240,7 +262,7 @@ module Net # :nodoc:
|
|
240
262
|
if arg.kind_of? Hash
|
241
263
|
new_from_hash(arg)
|
242
264
|
else
|
243
|
-
raise
|
265
|
+
raise ArgumentError, "Wrong argument class `#{arg.class}'"
|
244
266
|
end
|
245
267
|
end
|
246
268
|
|
@@ -262,7 +284,7 @@ module Net # :nodoc:
|
|
262
284
|
o.send(:new_from_binary, arg)
|
263
285
|
o
|
264
286
|
else
|
265
|
-
raise
|
287
|
+
raise ArgumentError, "Wrong argument class `#{arg.class}'"
|
266
288
|
end
|
267
289
|
end
|
268
290
|
|
@@ -362,13 +384,13 @@ module Net # :nodoc:
|
|
362
384
|
#
|
363
385
|
def id=(val)
|
364
386
|
if @@id_arr.include? val
|
365
|
-
raise
|
387
|
+
raise DuplicateIDError, "ID `#{val}' already used"
|
366
388
|
end
|
367
389
|
if (1..65535).include? val
|
368
390
|
@id = val
|
369
391
|
@@id_arr.push val
|
370
392
|
else
|
371
|
-
raise
|
393
|
+
raise ArgumentError, "ID `#{val}' out of range"
|
372
394
|
end
|
373
395
|
end
|
374
396
|
|
@@ -393,7 +415,7 @@ module Net # :nodoc:
|
|
393
415
|
when 0,1
|
394
416
|
@qr = val
|
395
417
|
else
|
396
|
-
raise
|
418
|
+
raise ArgumentError, ":qr must be true(or 1) or false(or 0)"
|
397
419
|
end
|
398
420
|
end
|
399
421
|
|
@@ -431,7 +453,7 @@ module Net # :nodoc:
|
|
431
453
|
if (0..2).include? val
|
432
454
|
@opCode = val
|
433
455
|
else
|
434
|
-
raise
|
456
|
+
raise WrongOpcodeError, "Wrong opCode value (#{val}), must be QUERY, IQUERY or STATUS"
|
435
457
|
end
|
436
458
|
end
|
437
459
|
|
@@ -465,7 +487,7 @@ module Net # :nodoc:
|
|
465
487
|
when 0,1
|
466
488
|
@aa = val
|
467
489
|
else
|
468
|
-
raise
|
490
|
+
raise ArgumentError, ":aa must be true(or 1) or false(or 0)"
|
469
491
|
end
|
470
492
|
end
|
471
493
|
|
@@ -503,7 +525,7 @@ module Net # :nodoc:
|
|
503
525
|
when 0,1
|
504
526
|
@tc = val
|
505
527
|
else
|
506
|
-
raise
|
528
|
+
raise ArgumentError, ":tc must be true(or 1) or false(or 0)"
|
507
529
|
end
|
508
530
|
end
|
509
531
|
|
@@ -535,7 +557,7 @@ module Net # :nodoc:
|
|
535
557
|
when 0
|
536
558
|
@rd = 0
|
537
559
|
else
|
538
|
-
raise
|
560
|
+
raise WrongRecursiveError, "Wrong value (#{val}), please specify true (1) or false (0)"
|
539
561
|
end
|
540
562
|
end
|
541
563
|
|
@@ -568,7 +590,7 @@ module Net # :nodoc:
|
|
568
590
|
when 0,1
|
569
591
|
@ra = val
|
570
592
|
else
|
571
|
-
raise
|
593
|
+
raise ArgumentError, ":ra must be true(or 1) or false(or 0)"
|
572
594
|
end
|
573
595
|
end
|
574
596
|
|
@@ -592,7 +614,7 @@ module Net # :nodoc:
|
|
592
614
|
when 0,1
|
593
615
|
@cd = val
|
594
616
|
else
|
595
|
-
raise
|
617
|
+
raise ArgumentError, ":cd must be true(or 1) or false(or 0)"
|
596
618
|
end
|
597
619
|
end
|
598
620
|
|
@@ -620,7 +642,7 @@ module Net # :nodoc:
|
|
620
642
|
when 0,1
|
621
643
|
@ad = val
|
622
644
|
else
|
623
|
-
raise
|
645
|
+
raise ArgumentError, ":ad must be true(or 1) or false(or 0)"
|
624
646
|
end
|
625
647
|
end
|
626
648
|
|
@@ -659,7 +681,7 @@ module Net # :nodoc:
|
|
659
681
|
if (0..65535).include? val
|
660
682
|
@qdCount = val
|
661
683
|
else
|
662
|
-
raise
|
684
|
+
raise WrongCountError, "Wrong number of count (#{val}), must be 0-65535"
|
663
685
|
end
|
664
686
|
end
|
665
687
|
|
@@ -669,7 +691,7 @@ module Net # :nodoc:
|
|
669
691
|
if (0..65535).include? val
|
670
692
|
@anCount = val
|
671
693
|
else
|
672
|
-
raise
|
694
|
+
raise WrongCountError, "Wrong number of count (#{val}), must be 0-65535"
|
673
695
|
end
|
674
696
|
end
|
675
697
|
|
@@ -679,7 +701,7 @@ module Net # :nodoc:
|
|
679
701
|
if (0..65535).include? val
|
680
702
|
@nsCount = val
|
681
703
|
else
|
682
|
-
raise
|
704
|
+
raise WrongCountError, "Wrong number of count (#{val}), must be 0-65535"
|
683
705
|
end
|
684
706
|
end
|
685
707
|
|
@@ -689,7 +711,7 @@ module Net # :nodoc:
|
|
689
711
|
if (0..65535).include? val
|
690
712
|
@arCount = val
|
691
713
|
else
|
692
|
-
raise
|
714
|
+
raise WrongCountError, "Wrong number of count: `#{val}' must be 0-65535"
|
693
715
|
end
|
694
716
|
end
|
695
717
|
|
@@ -706,7 +728,7 @@ module Net # :nodoc:
|
|
706
728
|
|
707
729
|
def new_from_binary(str)
|
708
730
|
unless str.size == Net::DNS::HFIXEDSZ
|
709
|
-
raise
|
731
|
+
raise ArgumentError, "Header binary data has wrong size: `#{str.size}' bytes"
|
710
732
|
end
|
711
733
|
arr = str.unpack("n C2 n4")
|
712
734
|
@id = arr[0]
|
@@ -739,23 +761,7 @@ module Net # :nodoc:
|
|
739
761
|
q
|
740
762
|
end
|
741
763
|
|
742
|
-
end
|
743
|
-
|
744
|
-
end # class DNS
|
745
|
-
end # module Net
|
746
|
-
|
747
|
-
|
748
|
-
class HeaderArgumentError < ArgumentError # :nodoc: all
|
749
|
-
end
|
750
|
-
|
751
|
-
class HeaderWrongCount < ArgumentError # :nodoc: all
|
752
|
-
end
|
753
|
-
|
754
|
-
class HeaderWrongRecursive < ArgumentError # :nodoc: all
|
755
|
-
end
|
756
|
-
|
757
|
-
class HeaderWrongOpcode < ArgumentError # :nodoc: all
|
758
|
-
end
|
764
|
+
end
|
759
765
|
|
760
|
-
|
761
|
-
end
|
766
|
+
end
|
767
|
+
end
|