bluemonk-net-dns 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/AUTHORS +10 -0
- data/CHANGELOG +7 -0
- data/INSTALL +8 -0
- data/README.rdoc +150 -0
- data/Rakefile +93 -0
- data/THANKS +24 -0
- data/VERSION.yml +4 -0
- data/demo/check_soa.rb +120 -0
- data/demo/threads.rb +22 -0
- data/lib/net/dns/dns.rb +117 -0
- data/lib/net/dns/header.rb +761 -0
- data/lib/net/dns/names/names.rb +109 -0
- data/lib/net/dns/packet.rb +581 -0
- data/lib/net/dns/question.rb +195 -0
- data/lib/net/dns/resolver/socks.rb +154 -0
- data/lib/net/dns/resolver/timeouts.rb +73 -0
- data/lib/net/dns/resolver.rb +1267 -0
- data/lib/net/dns/rr/a.rb +121 -0
- data/lib/net/dns/rr/aaaa.rb +92 -0
- data/lib/net/dns/rr/classes.rb +148 -0
- data/lib/net/dns/rr/cname.rb +69 -0
- data/lib/net/dns/rr/hinfo.rb +74 -0
- data/lib/net/dns/rr/mr.rb +68 -0
- data/lib/net/dns/rr/mx.rb +74 -0
- data/lib/net/dns/rr/ns.rb +70 -0
- data/lib/net/dns/rr/null.rb +61 -0
- data/lib/net/dns/rr/ptr.rb +71 -0
- data/lib/net/dns/rr/soa.rb +85 -0
- data/lib/net/dns/rr/srv.rb +57 -0
- data/lib/net/dns/rr/txt.rb +72 -0
- data/lib/net/dns/rr/types.rb +200 -0
- data/lib/net/dns/rr.rb +406 -0
- data/setup.rb +1360 -0
- data/test/net/dns/resolver/test_timeouts.rb +59 -0
- data/test/net/dns/rr/test_a.rb +72 -0
- data/test/net/dns/rr/test_classes.rb +73 -0
- data/test/net/dns/rr/test_ns.rb +66 -0
- data/test/net/dns/rr/test_types.rb +127 -0
- data/test/net/dns/test_header.rb +170 -0
- data/test/net/dns/test_packet.rb +42 -0
- data/test/net/dns/test_question.rb +54 -0
- data/test/net/dns/test_rr.rb +133 -0
- metadata +105 -0
@@ -0,0 +1,61 @@
|
|
1
|
+
##
|
2
|
+
#
|
3
|
+
# Net::DNS::RR::NULL
|
4
|
+
#
|
5
|
+
# $Id: NULL.rb,v 1.5 2006/07/28 07:33:36 bluemonk Exp $
|
6
|
+
#
|
7
|
+
##
|
8
|
+
|
9
|
+
|
10
|
+
module Net
|
11
|
+
module DNS
|
12
|
+
class RR
|
13
|
+
|
14
|
+
#------------------------------------------------------------
|
15
|
+
# RR type NULL
|
16
|
+
#------------------------------------------------------------
|
17
|
+
class NULL < RR
|
18
|
+
attr_reader :null
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def build_pack
|
23
|
+
@null_pack = @null
|
24
|
+
@rdlength = @null_pack.size
|
25
|
+
end
|
26
|
+
|
27
|
+
def set_type
|
28
|
+
@type = Net::DNS::RR::RRTypes.new("NULL")
|
29
|
+
end
|
30
|
+
|
31
|
+
def get_data
|
32
|
+
@null_pack
|
33
|
+
end
|
34
|
+
|
35
|
+
def get_inspect
|
36
|
+
"#@null"
|
37
|
+
end
|
38
|
+
|
39
|
+
def subclass_new_from_hash(args)
|
40
|
+
if args.has_key? :null
|
41
|
+
@null = args[:null]
|
42
|
+
else
|
43
|
+
raise RRArgumentError, ":null field is mandatory but missing"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def subclass_new_from_string(str)
|
48
|
+
@null = str.strip
|
49
|
+
end
|
50
|
+
|
51
|
+
def subclass_new_from_binary(data,offset)
|
52
|
+
@null = data[offset..offset+@rdlength]
|
53
|
+
return offset + @rdlength
|
54
|
+
end
|
55
|
+
|
56
|
+
end # class NULL
|
57
|
+
|
58
|
+
end # class RR
|
59
|
+
end # module DNS
|
60
|
+
end # module Net
|
61
|
+
|
@@ -0,0 +1,71 @@
|
|
1
|
+
##
|
2
|
+
#
|
3
|
+
# Net::DNS::RR::PTR
|
4
|
+
#
|
5
|
+
# $Id: PTR.rb,v 1.5 2006/07/28 07:33:36 bluemonk Exp $
|
6
|
+
#
|
7
|
+
##
|
8
|
+
|
9
|
+
module Net
|
10
|
+
module DNS
|
11
|
+
class RR
|
12
|
+
|
13
|
+
#------------------------------------------------------------
|
14
|
+
# RR type PTR
|
15
|
+
#------------------------------------------------------------
|
16
|
+
class PTR < RR
|
17
|
+
|
18
|
+
# Getter for PTR resource
|
19
|
+
def ptr
|
20
|
+
@ptrdname.to_s
|
21
|
+
end
|
22
|
+
alias_method :ptrdname, :ptr
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def check_ptr(str)
|
27
|
+
IPAddr.new str
|
28
|
+
rescue
|
29
|
+
raise RRArgumentError, "PTR section not valid"
|
30
|
+
end
|
31
|
+
|
32
|
+
def build_pack
|
33
|
+
@ptrdname_pack = pack_name(@ptrdname)
|
34
|
+
@rdlength = @ptrdname_pack.size
|
35
|
+
end
|
36
|
+
|
37
|
+
def set_type
|
38
|
+
@type = Net::DNS::RR::Types.new("PTR")
|
39
|
+
end
|
40
|
+
|
41
|
+
def get_data
|
42
|
+
@ptrdname_pack
|
43
|
+
end
|
44
|
+
|
45
|
+
def get_inspect
|
46
|
+
"#@ptrdname"
|
47
|
+
end
|
48
|
+
|
49
|
+
def subclass_new_from_hash(args)
|
50
|
+
if args.has_key? :ptrdname or args.has_key? :ptr
|
51
|
+
@ptrdname = args[0][:ptrdname]
|
52
|
+
else
|
53
|
+
raise RRArgumentError, ":ptrdname or :ptr field is mandatory but missing"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def subclass_new_from_string(str)
|
58
|
+
@ptrdname = check_ptr(str)
|
59
|
+
end
|
60
|
+
|
61
|
+
def subclass_new_from_binary(data,offset)
|
62
|
+
@ptrdname,offset = dn_expand(data,offset)
|
63
|
+
return offset
|
64
|
+
end
|
65
|
+
|
66
|
+
end # class PTR
|
67
|
+
|
68
|
+
end # class RR
|
69
|
+
end # module DNS
|
70
|
+
end # module Net
|
71
|
+
|
@@ -0,0 +1,85 @@
|
|
1
|
+
##
|
2
|
+
#
|
3
|
+
# Net::DNS::RR::SOA
|
4
|
+
#
|
5
|
+
# $Id: SOA.rb,v 1.4 2006/07/28 07:33:36 bluemonk Exp $
|
6
|
+
#
|
7
|
+
##
|
8
|
+
|
9
|
+
module Net
|
10
|
+
module DNS
|
11
|
+
class RR
|
12
|
+
|
13
|
+
#------------------------------------------------------------
|
14
|
+
# RR type SOA
|
15
|
+
#------------------------------------------------------------
|
16
|
+
class SOA < RR
|
17
|
+
attr_reader :mname, :rname, :serial, :refresh, :retry, :expire, :minimum
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def build_pack
|
22
|
+
@soa_pack = pack_name(@mname)
|
23
|
+
@soa_pack += pack_name(@rname)
|
24
|
+
@soa_pack += [@serial,@refresh,@retry,@expire,@minimum].pack("N5")
|
25
|
+
end
|
26
|
+
|
27
|
+
def set_type
|
28
|
+
@type = Net::DNS::RR::Types.new("SOA")
|
29
|
+
end
|
30
|
+
|
31
|
+
def get_data
|
32
|
+
@soa_pack
|
33
|
+
end
|
34
|
+
|
35
|
+
def get_inspect
|
36
|
+
"#@mname #@rname #@serial #@refresh #@retry #@expire #@minimum"
|
37
|
+
end
|
38
|
+
|
39
|
+
def subclass_new_from_hash(args)
|
40
|
+
if args.has_key? :rdata
|
41
|
+
subclass_new_from_string(args[:rdata])
|
42
|
+
else
|
43
|
+
[:mname,:rname,:serial,:refresh,:retry,:expire,:minimum].each do |key|
|
44
|
+
raise RRArgumentError, "Missing field :#{key}" unless args.has_key? key
|
45
|
+
end
|
46
|
+
@mname = args[:mname] if valid? args[:mname]
|
47
|
+
@rname = args[:rname] if valid? args[:rname]
|
48
|
+
@serial = args[:serial] if number? args[:serial]
|
49
|
+
@refresh = args[:refresh] if number? args[:refresh]
|
50
|
+
@retry = args[:retry] if number? args[:retry]
|
51
|
+
@expire = args[:expire] if number? args[:expire]
|
52
|
+
@minimum = args[:minimum] if number? args[:minimum]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def number?(num)
|
57
|
+
if num.kind_of? Integer and num > 0
|
58
|
+
true
|
59
|
+
else
|
60
|
+
raise RRArgumentError, "Wrong format field: #{num} not a number or less than zero"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def subclass_new_from_string(str)
|
65
|
+
mname,rname,serial,refresh,ret,expire,minimum = str.strip.split(" ")
|
66
|
+
@mname = mname if valid? mname
|
67
|
+
@rname = rname if valid? rname
|
68
|
+
@serial,@refresh,@retry,@expire,@minimum = [serial,refresh,ret,expire,minimum].collect do |i|
|
69
|
+
i.to_i if valid? i.to_i
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def subclass_new_from_binary(data,offset)
|
74
|
+
@mname,offset = dn_expand(data,offset)
|
75
|
+
@rname,offset = dn_expand(data,offset)
|
76
|
+
@serial,@refresh,@retry,@expire,@minimum = data.unpack("@#{offset} N5")
|
77
|
+
return offset + 5*Net::DNS::INT32SZ
|
78
|
+
end
|
79
|
+
|
80
|
+
end # class SOA
|
81
|
+
|
82
|
+
end # class RR
|
83
|
+
end # module DNS
|
84
|
+
end # module Net
|
85
|
+
|
@@ -0,0 +1,57 @@
|
|
1
|
+
##
|
2
|
+
#
|
3
|
+
# Net::DNS::RR::SRV
|
4
|
+
#
|
5
|
+
# $Id$
|
6
|
+
#
|
7
|
+
##
|
8
|
+
|
9
|
+
|
10
|
+
module Net
|
11
|
+
module DNS
|
12
|
+
class RR
|
13
|
+
|
14
|
+
#------------------------------------------------------------
|
15
|
+
# RR type SRV
|
16
|
+
#------------------------------------------------------------
|
17
|
+
class SRV < RR
|
18
|
+
|
19
|
+
attr_reader :priority, :weight, :port, :host
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def build_pack
|
24
|
+
str = ""
|
25
|
+
end
|
26
|
+
|
27
|
+
def set_type
|
28
|
+
@type = Net::DNS::RR::Types.new("SRV")
|
29
|
+
end
|
30
|
+
|
31
|
+
def subclass_new_from_binary(data,offset)
|
32
|
+
off_end = offset + @rdlength
|
33
|
+
@priority, @weight, @port = data.unpack("@#{offset} n n n")
|
34
|
+
offset+=6
|
35
|
+
|
36
|
+
@host=[]
|
37
|
+
while offset < off_end
|
38
|
+
len = data.unpack("@#{offset} C")[0]
|
39
|
+
offset += 1
|
40
|
+
str = data[offset..offset+len-1]
|
41
|
+
offset += len
|
42
|
+
@host << str
|
43
|
+
end
|
44
|
+
@host=@host.join(".")
|
45
|
+
offset
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
end # class SRV
|
50
|
+
end # class RR
|
51
|
+
|
52
|
+
|
53
|
+
end # module DNS
|
54
|
+
end # module Net
|
55
|
+
|
56
|
+
|
57
|
+
|
@@ -0,0 +1,72 @@
|
|
1
|
+
##
|
2
|
+
#
|
3
|
+
# Net::DNS::RR::TXT
|
4
|
+
#
|
5
|
+
# $Id: TXT.rb,v 1.4 2006/07/28 07:33:36 bluemonk Exp $
|
6
|
+
#
|
7
|
+
##
|
8
|
+
|
9
|
+
|
10
|
+
module Net
|
11
|
+
module DNS
|
12
|
+
class RR
|
13
|
+
|
14
|
+
#------------------------------------------------------------
|
15
|
+
# RR type TXT
|
16
|
+
#------------------------------------------------------------
|
17
|
+
class TXT < RR
|
18
|
+
attr_reader :txt
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def build_pack
|
23
|
+
str = ""
|
24
|
+
@txt.split(" ").each do |txt|
|
25
|
+
str += [txt.length,txt].pack("C a*")
|
26
|
+
end
|
27
|
+
@txt_pack = str
|
28
|
+
@rdlength = @txt_pack.size
|
29
|
+
end
|
30
|
+
|
31
|
+
def set_type
|
32
|
+
@type = Net::DNS::RR::Types.new("TXT")
|
33
|
+
end
|
34
|
+
|
35
|
+
def get_data
|
36
|
+
@txt_pack
|
37
|
+
end
|
38
|
+
|
39
|
+
def subclass_new_from_hash(args)
|
40
|
+
if args.has_key? :txt
|
41
|
+
@txt = args[:txt].strip
|
42
|
+
else
|
43
|
+
raise RRArgumentError, ":txt field is mandatory but missing"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def subclass_new_from_string(str)
|
48
|
+
@txt = str.strip
|
49
|
+
end
|
50
|
+
|
51
|
+
def subclass_new_from_binary(data,offset)
|
52
|
+
off_end = offset + @rdlength
|
53
|
+
@txt = ""
|
54
|
+
while offset < off_end
|
55
|
+
len = data.unpack("@#{offset} C")[0]
|
56
|
+
offset += 1
|
57
|
+
str = data[offset..offset+len-1]
|
58
|
+
offset += len
|
59
|
+
@txt << str << " "
|
60
|
+
end
|
61
|
+
return offset
|
62
|
+
end
|
63
|
+
|
64
|
+
end # class TXT
|
65
|
+
|
66
|
+
end # class RR
|
67
|
+
end # module DNS
|
68
|
+
end # module Net
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
@@ -0,0 +1,200 @@
|
|
1
|
+
module Net # :nodoc:
|
2
|
+
module DNS
|
3
|
+
|
4
|
+
class RR
|
5
|
+
|
6
|
+
#
|
7
|
+
# This is an auxiliary class to hadle RR type field in a DNS packet.
|
8
|
+
#
|
9
|
+
class Types
|
10
|
+
|
11
|
+
# :nodoc:
|
12
|
+
Types = { # :nodoc:
|
13
|
+
'SIGZERO' => 0, # RFC2931 consider this a pseudo type
|
14
|
+
'A' => 1, # RFC 1035, Section 3.4.1
|
15
|
+
'NS' => 2, # RFC 1035, Section 3.3.11
|
16
|
+
'MD' => 3, # RFC 1035, Section 3.3.4 (obsolete)
|
17
|
+
'MF' => 4, # RFC 1035, Section 3.3.5 (obsolete)
|
18
|
+
'CNAME' => 5, # RFC 1035, Section 3.3.1
|
19
|
+
'SOA' => 6, # RFC 1035, Section 3.3.13
|
20
|
+
'MB' => 7, # RFC 1035, Section 3.3.3
|
21
|
+
'MG' => 8, # RFC 1035, Section 3.3.6
|
22
|
+
'MR' => 9, # RFC 1035, Section 3.3.8
|
23
|
+
'NULL' => 10, # RFC 1035, Section 3.3.10
|
24
|
+
'WKS' => 11, # RFC 1035, Section 3.4.2 (deprecated)
|
25
|
+
'PTR' => 12, # RFC 1035, Section 3.3.12
|
26
|
+
'HINFO' => 13, # RFC 1035, Section 3.3.2
|
27
|
+
'MINFO' => 14, # RFC 1035, Section 3.3.7
|
28
|
+
'MX' => 15, # RFC 1035, Section 3.3.9
|
29
|
+
'TXT' => 16, # RFC 1035, Section 3.3.14
|
30
|
+
'RP' => 17, # RFC 1183, Section 2.2
|
31
|
+
'AFSDB' => 18, # RFC 1183, Section 1
|
32
|
+
'X25' => 19, # RFC 1183, Section 3.1
|
33
|
+
'ISDN' => 20, # RFC 1183, Section 3.2
|
34
|
+
'RT' => 21, # RFC 1183, Section 3.3
|
35
|
+
'NSAP' => 22, # RFC 1706, Section 5
|
36
|
+
'NSAP_PTR' => 23, # RFC 1348 (obsolete)
|
37
|
+
# The following 2 RRs are impemented in Net::DNS::SEC, TODO
|
38
|
+
'SIG' => 24, # RFC 2535, Section 4.1
|
39
|
+
'KEY' => 25, # RFC 2535, Section 3.1
|
40
|
+
'PX' => 26, # RFC 2163,
|
41
|
+
'GPOS' => 27, # RFC 1712 (obsolete)
|
42
|
+
'AAAA' => 28, # RFC 1886, Section 2.1
|
43
|
+
'LOC' => 29, # RFC 1876
|
44
|
+
# The following RR is impemented in Net::DNS::SEC, TODO
|
45
|
+
'NXT' => 30, # RFC 2535, Section 5.2
|
46
|
+
'EID' => 31, # draft-ietf-nimrod-dns-xx.txt
|
47
|
+
'NIMLOC' => 32, # draft-ietf-nimrod-dns-xx.txt
|
48
|
+
'SRV' => 33, # RFC 2052
|
49
|
+
'ATMA' => 34, # ???
|
50
|
+
'NAPTR' => 35, # RFC 2168
|
51
|
+
'KX' => 36, # RFC 2230
|
52
|
+
'CERT' => 37, # RFC 2538
|
53
|
+
'DNAME' => 39, # RFC 2672
|
54
|
+
'OPT' => 41, # RFC 2671
|
55
|
+
# The following 4 RRs are impemented in Net::DNS::SEC TODO
|
56
|
+
'DS' => 43, # draft-ietf-dnsext-delegation-signer
|
57
|
+
'SSHFP' => 44, # draft-ietf-secsh-dns (No RFC # yet at time of coding)
|
58
|
+
'RRSIG' => 46, # draft-ietf-dnsext-dnssec-2535typecode-change
|
59
|
+
'NSEC' => 47, # draft-ietf-dnsext-dnssec-2535typecode-change
|
60
|
+
'DNSKEY' => 48, # draft-ietf-dnsext-dnssec-2535typecode-change
|
61
|
+
'UINFO' => 100, # non-standard
|
62
|
+
'UID' => 101, # non-standard
|
63
|
+
'GID' => 102, # non-standard
|
64
|
+
'UNSPEC' => 103, # non-standard
|
65
|
+
'TKEY' => 249, # RFC 2930
|
66
|
+
'TSIG' => 250, # RFC 2931
|
67
|
+
'IXFR' => 251, # RFC 1995
|
68
|
+
'AXFR' => 252, # RFC 1035
|
69
|
+
'MAILB' => 253, # RFC 1035 (MB, MG, MR)
|
70
|
+
'MAILA' => 254, # RFC 1035 (obsolete - see MX)
|
71
|
+
'ANY' => 255, # RFC 1035
|
72
|
+
}
|
73
|
+
|
74
|
+
# The default value when type is nil in Resource Records
|
75
|
+
@@default = Types["A"]
|
76
|
+
|
77
|
+
# Be able to control the default type to assign when
|
78
|
+
# type is +nil+. Default to +A+
|
79
|
+
def self.default=(str)
|
80
|
+
if Types.has_key? str
|
81
|
+
@@default = Types[str]
|
82
|
+
else
|
83
|
+
raise TypeArgumentError, "Unknown type #{str}"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# Checks whether +type+ is a valid RR type.
|
88
|
+
def self.valid?(type)
|
89
|
+
case type
|
90
|
+
when String
|
91
|
+
return Types.has_key?(type)
|
92
|
+
when Fixnum
|
93
|
+
return Types.invert.has_key?(type)
|
94
|
+
else
|
95
|
+
raise TypeArgumentError, "Wrong type class: #{type.class}"
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
# Returns the type in string format, as "A" or "NS",
|
100
|
+
# given the numeric value
|
101
|
+
def self.to_str(type)
|
102
|
+
case type
|
103
|
+
when Fixnum
|
104
|
+
if Types.invert.has_key? type
|
105
|
+
return Types.invert[type]
|
106
|
+
else
|
107
|
+
raise TypeArgumentError, "Unknown type number #{type}"
|
108
|
+
end
|
109
|
+
else
|
110
|
+
raise TypeArgumentError, "Wrong type class: #{type.class}"
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
# Gives in output the keys from the +Types+ hash
|
115
|
+
# in a format suited for regexps
|
116
|
+
def self.regexp
|
117
|
+
Types.keys.join("|")
|
118
|
+
end
|
119
|
+
|
120
|
+
# Creates a new object representing an RR type. Performs some
|
121
|
+
# checks on the argument validity too. Il +type+ is +nil+, the
|
122
|
+
# default value is +ANY+ or the one set with Types.default=
|
123
|
+
def initialize(type)
|
124
|
+
case type
|
125
|
+
when String
|
126
|
+
# type in the form "A" or "NS"
|
127
|
+
new_from_string(type.upcase)
|
128
|
+
when Fixnum
|
129
|
+
# type in numeric form
|
130
|
+
new_from_num(type)
|
131
|
+
when nil
|
132
|
+
# default type, control with Types.default=
|
133
|
+
@str = Types.invert[@@default]
|
134
|
+
@num = @@default
|
135
|
+
else
|
136
|
+
raise TypeArgumentError, "Wrong type class: #{type.class}"
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
# Returns the type in number format
|
141
|
+
# (default for normal use)
|
142
|
+
def inspect
|
143
|
+
@num
|
144
|
+
end
|
145
|
+
|
146
|
+
# Returns the type in string format,
|
147
|
+
# i.d. "A" or "NS" or such a string.
|
148
|
+
def to_s
|
149
|
+
@str
|
150
|
+
end
|
151
|
+
|
152
|
+
# Returns the type in numeric format,
|
153
|
+
# usable by the pack methods for data transfers
|
154
|
+
def to_i
|
155
|
+
@num.to_i
|
156
|
+
end
|
157
|
+
|
158
|
+
# Should be used only for testing purpouses
|
159
|
+
def to_str
|
160
|
+
@num.to_s
|
161
|
+
end
|
162
|
+
|
163
|
+
private
|
164
|
+
|
165
|
+
# Constructor for string data type,
|
166
|
+
# *PRIVATE* method
|
167
|
+
def new_from_string(type)
|
168
|
+
case type
|
169
|
+
when /^TYPE\\d+/
|
170
|
+
# TODO!!!
|
171
|
+
else
|
172
|
+
# String with name of type
|
173
|
+
if Types.has_key? type
|
174
|
+
@str = type
|
175
|
+
@num = Types[type]
|
176
|
+
else
|
177
|
+
raise TypeArgumentError, "Unknown type #{type}"
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
# Contructor for numeric data type
|
183
|
+
# *PRIVATE* method
|
184
|
+
def new_from_num(type)
|
185
|
+
if Types.invert.has_key? type
|
186
|
+
@num = type
|
187
|
+
@str = Types.invert[type]
|
188
|
+
else
|
189
|
+
raise TypeArgumentError, "Unkown type number #{type}"
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
end # class Types
|
194
|
+
|
195
|
+
end # class RR
|
196
|
+
end # module DNS
|
197
|
+
end # module Net
|
198
|
+
|
199
|
+
class TypeArgumentError < ArgumentError # :nodoc:
|
200
|
+
end
|