dnsruby 1.55 → 1.56.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (158) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +96 -0
  3. data/Rakefile +30 -29
  4. data/demo/axfr.rb +93 -93
  5. data/demo/check_soa.rb +99 -99
  6. data/demo/check_zone.rb +59 -59
  7. data/demo/digdlv.rb +43 -43
  8. data/demo/digroot.rb +34 -34
  9. data/demo/example_recurse.rb +14 -14
  10. data/demo/mresolv.rb +30 -30
  11. data/demo/mx.rb +31 -31
  12. data/demo/rubydig.rb +37 -37
  13. data/demo/to_resolve.txt +3088 -3088
  14. data/demo/trace_dns.rb +46 -46
  15. data/lib/dnsruby.rb +161 -526
  16. data/lib/dnsruby/DNS.rb +305 -0
  17. data/lib/{Dnsruby/Cache.rb → dnsruby/cache.rb} +152 -152
  18. data/lib/{Dnsruby → dnsruby}/code_mapper.rb +48 -52
  19. data/lib/dnsruby/code_mappers.rb +295 -0
  20. data/lib/{Dnsruby/Config.rb → dnsruby/config.rb} +454 -454
  21. data/lib/{Dnsruby → dnsruby}/dnssec.rb +91 -91
  22. data/lib/{Dnsruby/Hosts.rb → dnsruby/hosts.rb} +125 -125
  23. data/lib/{Dnsruby → dnsruby}/ipv4.rb +26 -26
  24. data/lib/{Dnsruby → dnsruby}/ipv6.rb +42 -42
  25. data/lib/{Dnsruby → dnsruby}/key_cache.rb +29 -29
  26. data/lib/dnsruby/message/decoder.rb +164 -0
  27. data/lib/dnsruby/message/encoder.rb +75 -0
  28. data/lib/dnsruby/message/header.rb +249 -0
  29. data/lib/dnsruby/message/message.rb +629 -0
  30. data/lib/dnsruby/message/question.rb +86 -0
  31. data/lib/dnsruby/message/section.rb +96 -0
  32. data/lib/{Dnsruby → dnsruby}/name.rb +141 -141
  33. data/lib/dnsruby/packet_sender.rb +661 -0
  34. data/lib/{Dnsruby/Recursor.rb → dnsruby/recursor.rb} +235 -233
  35. data/lib/dnsruby/resolv.rb +113 -0
  36. data/lib/dnsruby/resolver.rb +1192 -0
  37. data/lib/dnsruby/resource/A.rb +56 -0
  38. data/lib/dnsruby/resource/AAAA.rb +54 -0
  39. data/lib/{Dnsruby → dnsruby}/resource/AFSDB.rb +68 -68
  40. data/lib/{Dnsruby → dnsruby}/resource/CERT.rb +105 -105
  41. data/lib/{Dnsruby → dnsruby}/resource/DHCID.rb +54 -54
  42. data/lib/dnsruby/resource/DLV.rb +27 -0
  43. data/lib/{Dnsruby → dnsruby}/resource/DNSKEY.rb +372 -372
  44. data/lib/{Dnsruby → dnsruby}/resource/DS.rb +255 -255
  45. data/lib/{Dnsruby → dnsruby}/resource/HINFO.rb +71 -71
  46. data/lib/{Dnsruby → dnsruby}/resource/HIP.rb +29 -29
  47. data/lib/{Dnsruby → dnsruby}/resource/IN.rb +30 -30
  48. data/lib/{Dnsruby → dnsruby}/resource/IPSECKEY.rb +31 -31
  49. data/lib/{Dnsruby → dnsruby}/resource/ISDN.rb +62 -62
  50. data/lib/{Dnsruby → dnsruby}/resource/KX.rb +65 -65
  51. data/lib/{Dnsruby → dnsruby}/resource/LOC.rb +263 -263
  52. data/lib/{Dnsruby → dnsruby}/resource/MINFO.rb +69 -69
  53. data/lib/{Dnsruby → dnsruby}/resource/MX.rb +65 -65
  54. data/lib/{Dnsruby → dnsruby}/resource/NAPTR.rb +98 -98
  55. data/lib/{Dnsruby → dnsruby}/resource/NSAP.rb +171 -171
  56. data/lib/dnsruby/resource/NSEC.rb +275 -0
  57. data/lib/dnsruby/resource/NSEC3.rb +332 -0
  58. data/lib/dnsruby/resource/NSEC3PARAM.rb +135 -0
  59. data/lib/dnsruby/resource/OPT.rb +272 -0
  60. data/lib/{Dnsruby → dnsruby}/resource/PX.rb +70 -70
  61. data/lib/{Dnsruby → dnsruby}/resource/RP.rb +75 -75
  62. data/lib/dnsruby/resource/RR.rb +421 -0
  63. data/lib/dnsruby/resource/RRSIG.rb +275 -0
  64. data/lib/dnsruby/resource/RRSet.rb +190 -0
  65. data/lib/{Dnsruby → dnsruby}/resource/RT.rb +67 -67
  66. data/lib/{Dnsruby → dnsruby}/resource/SOA.rb +94 -94
  67. data/lib/dnsruby/resource/SPF.rb +29 -0
  68. data/lib/dnsruby/resource/SRV.rb +112 -0
  69. data/lib/{Dnsruby → dnsruby}/resource/SSHFP.rb +14 -14
  70. data/lib/dnsruby/resource/TKEY.rb +163 -0
  71. data/lib/dnsruby/resource/TSIG.rb +593 -0
  72. data/lib/{Dnsruby → dnsruby}/resource/TXT.rb +191 -191
  73. data/lib/dnsruby/resource/X25.rb +55 -0
  74. data/lib/{Dnsruby → dnsruby}/resource/domain_name.rb +25 -25
  75. data/lib/{Dnsruby → dnsruby}/resource/generic.rb +80 -80
  76. data/lib/dnsruby/resource/resource.rb +25 -0
  77. data/lib/{Dnsruby → dnsruby}/select_thread.rb +148 -148
  78. data/lib/{Dnsruby/SingleResolver.rb → dnsruby/single_resolver.rb} +60 -60
  79. data/lib/{Dnsruby → dnsruby}/single_verifier.rb +344 -344
  80. data/lib/dnsruby/the_log.rb +44 -0
  81. data/lib/dnsruby/update.rb +278 -0
  82. data/lib/dnsruby/validator_thread.rb +124 -0
  83. data/lib/dnsruby/version.rb +3 -0
  84. data/lib/{Dnsruby → dnsruby}/zone_reader.rb +93 -93
  85. data/lib/{Dnsruby → dnsruby}/zone_transfer.rb +377 -377
  86. data/test/spec_helper.rb +16 -0
  87. data/test/tc_axfr.rb +31 -34
  88. data/test/tc_cache.rb +32 -32
  89. data/test/tc_dlv.rb +28 -28
  90. data/test/tc_dns.rb +73 -76
  91. data/test/tc_dnskey.rb +31 -32
  92. data/test/tc_dnsruby.rb +50 -44
  93. data/test/tc_ds.rb +36 -36
  94. data/test/tc_escapedchars.rb +252 -255
  95. data/test/tc_hash.rb +17 -21
  96. data/test/tc_header.rb +48 -57
  97. data/test/tc_hip.rb +19 -22
  98. data/test/tc_ipseckey.rb +18 -21
  99. data/test/tc_keith.rb +300 -0
  100. data/test/tc_message.rb +87 -0
  101. data/test/tc_misc.rb +83 -87
  102. data/test/tc_name.rb +81 -84
  103. data/test/tc_naptr.rb +18 -21
  104. data/test/tc_nsec.rb +55 -55
  105. data/test/tc_nsec3.rb +23 -24
  106. data/test/tc_nsec3param.rb +20 -21
  107. data/test/tc_packet.rb +90 -93
  108. data/test/tc_packet_unique_push.rb +48 -51
  109. data/test/tc_question.rb +30 -33
  110. data/test/tc_queue.rb +16 -17
  111. data/test/tc_recur.rb +16 -17
  112. data/test/tc_res_config.rb +38 -41
  113. data/test/tc_res_env.rb +29 -32
  114. data/test/tc_res_file.rb +26 -29
  115. data/test/tc_res_opt.rb +62 -65
  116. data/test/tc_resolver.rb +287 -242
  117. data/test/tc_rr-opt.rb +70 -63
  118. data/test/tc_rr-txt.rb +68 -71
  119. data/test/tc_rr-unknown.rb +45 -48
  120. data/test/tc_rr.rb +76 -70
  121. data/test/tc_rrset.rb +21 -22
  122. data/test/tc_rrsig.rb +19 -20
  123. data/test/tc_single_resolver.rb +294 -297
  124. data/test/tc_soak.rb +199 -202
  125. data/test/tc_soak_base.rb +29 -34
  126. data/test/tc_sshfp.rb +20 -23
  127. data/test/tc_tcp.rb +32 -35
  128. data/test/tc_tkey.rb +41 -44
  129. data/test/tc_tsig.rb +81 -84
  130. data/test/tc_update.rb +108 -111
  131. data/test/tc_validator.rb +29 -29
  132. data/test/tc_verifier.rb +81 -82
  133. data/test/ts_dnsruby.rb +16 -15
  134. data/test/ts_offline.rb +62 -63
  135. data/test/ts_online.rb +115 -115
  136. metadata +155 -90
  137. data/README +0 -59
  138. data/lib/Dnsruby/DNS.rb +0 -305
  139. data/lib/Dnsruby/PacketSender.rb +0 -656
  140. data/lib/Dnsruby/Resolver.rb +0 -1189
  141. data/lib/Dnsruby/TheLog.rb +0 -44
  142. data/lib/Dnsruby/message.rb +0 -1230
  143. data/lib/Dnsruby/resource/A.rb +0 -56
  144. data/lib/Dnsruby/resource/AAAA.rb +0 -54
  145. data/lib/Dnsruby/resource/DLV.rb +0 -27
  146. data/lib/Dnsruby/resource/NSEC.rb +0 -298
  147. data/lib/Dnsruby/resource/NSEC3.rb +0 -340
  148. data/lib/Dnsruby/resource/NSEC3PARAM.rb +0 -135
  149. data/lib/Dnsruby/resource/OPT.rb +0 -213
  150. data/lib/Dnsruby/resource/RRSIG.rb +0 -275
  151. data/lib/Dnsruby/resource/SPF.rb +0 -29
  152. data/lib/Dnsruby/resource/SRV.rb +0 -112
  153. data/lib/Dnsruby/resource/TKEY.rb +0 -163
  154. data/lib/Dnsruby/resource/TSIG.rb +0 -593
  155. data/lib/Dnsruby/resource/X25.rb +0 -55
  156. data/lib/Dnsruby/resource/resource.rb +0 -678
  157. data/lib/Dnsruby/update.rb +0 -278
  158. data/lib/Dnsruby/validator_thread.rb +0 -124
@@ -1,33 +1,33 @@
1
- #--
2
- #Copyright 2007 Nominet UK
3
- #
4
- #Licensed under the Apache License, Version 2.0 (the "License");
5
- #you may not use this file except in compliance with the License.
6
- #You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- #Unless required by applicable law or agreed to in writing, software
11
- #distributed under the License is distributed on an "AS IS" BASIS,
12
- #WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- #See the License for the specific language governing permissions and
14
- #limitations under the License.
15
- #++
1
+ # --
2
+ # Copyright 2007 Nominet UK
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ # ++
16
16
  module Dnsruby
17
- # CodeMapper superclass looks after String to code mappings (e.g. OpCode, RCode, etc.)
17
+ # CodeMapper superclass looks after String to code mappings (e.g. OpCode, RCode, etc.)
18
18
  #
19
- # Subclasses simply define a mapping of codes to variable names, and CodeMapper provides utility methods.
19
+ # Subclasses simply define a mapping of codes to variable names, and CodeMapper provides utility methods.
20
20
  #
21
- # All strings will come out as upper case
21
+ # All strings will come out as upper case
22
22
  #
23
- # Example :
24
- # Types::AAAA or Types.AAAA
25
- # rcode.string or rcode.code
23
+ # Example :
24
+ # Types::AAAA or Types.AAAA
25
+ # rcode.string or rcode.code
26
26
  class CodeMapper # :nodoc: all
27
27
  include Comparable
28
-
28
+
29
29
  @@arrays = {}
30
-
30
+
31
31
  attr_accessor :string, :code
32
32
  alias to_code code
33
33
  alias to_i code
@@ -49,20 +49,16 @@ module Dnsruby
49
49
  @@arrays[self].strings.keys.each {|s| strings.push(s)}
50
50
  return strings
51
51
  end
52
-
53
- def CodeMapper.maxcode
54
- return @maxcode
55
- end
56
-
57
- # Creates the CodeMapper from the defined constants
52
+
53
+ # Creates the CodeMapper from the defined constants
58
54
  def CodeMapper.update
59
55
 
60
56
  @@arrays[self] = Arrays.new
61
-
57
+
62
58
  constants = self.constants - CodeMapper.constants
63
59
  constants.each do |i|
64
60
  @@arrays[self].strings.store(i.to_s, const_get(i))
65
- end
61
+ end
66
62
  @@arrays[self].maxcode = constants.length
67
63
  @@arrays[self].values = @@arrays[self].strings.invert
68
64
  @@arrays[self].stringsdown = Hash.new
@@ -70,8 +66,8 @@ module Dnsruby
70
66
  @@arrays[self].stringsdown.store(s.downcase, @@arrays[self].strings[s])
71
67
  end
72
68
  end
73
-
74
- # Add new a code to the CodeMapper
69
+
70
+ # Add new a code to the CodeMapper
75
71
  def CodeMapper.add_pair(string, code)
76
72
  array = @@arrays[self]
77
73
  array.strings.store(string, code)
@@ -79,23 +75,23 @@ module Dnsruby
79
75
  array.stringsdown.store(string.downcase, code)
80
76
  array.maxcode+=1
81
77
  end
82
-
78
+
83
79
  def unknown_string(arg) #:nodoc: all
84
80
  raise ArgumentError.new("String #{arg} not a member of #{self.class}")
85
81
  end
86
-
82
+
87
83
  def unknown_code(arg) #:nodoc: all
88
- # Be liberal in what you accept...
89
- # raise ArgumentError.new("Code #{arg} not a member of #{self.class}")
84
+ # Be liberal in what you accept...
85
+ # raise ArgumentError.new("Code #{arg} not a member of #{self.class}")
90
86
  Classes.add_pair(arg.to_s, arg)
91
87
  set_code(arg)
92
88
  end
93
-
89
+
94
90
  def self.method_missing(methId) #:nodoc: all
95
91
  str = methId.id2name
96
92
  return self.new(str)
97
93
  end
98
-
94
+
99
95
  def initialize(arg) #:nodoc: all
100
96
  array = @@arrays[self.class]
101
97
  if (arg.kind_of?String)
@@ -104,14 +100,14 @@ module Dnsruby
104
100
  if (code != nil)
105
101
  @code = code
106
102
  @string = array.values[@code]
107
- else
103
+ else
108
104
  unknown_string(arg)
109
105
  end
110
106
  elsif (arg.kind_of?Fixnum)
111
107
  if (array.values[arg] != nil)
112
108
  @code = arg
113
109
  @string = array.values[@code]
114
- else
110
+ else
115
111
  unknown_code(arg)
116
112
  end
117
113
  elsif (arg.kind_of?self.class)
@@ -121,7 +117,7 @@ module Dnsruby
121
117
  raise ArgumentError.new("Unknown argument #{arg} for #{self.class}")
122
118
  end
123
119
  end
124
-
120
+
125
121
  def set_string(arg)
126
122
  array = @@arrays[self.class]
127
123
  @code = array.stringsdown[arg.downcase]
@@ -132,23 +128,23 @@ module Dnsruby
132
128
  @code = arg
133
129
  @string = @@arrays[self.class].values[@code]
134
130
  end
135
-
131
+
136
132
  def hash
137
133
  @code
138
134
  end
139
135
 
140
136
  def inspect
141
137
  return @string
142
- end
143
-
138
+ end
139
+
144
140
  def CodeMapper.to_string(arg)
145
- if (arg.kind_of?String)
141
+ if (arg.kind_of?String)
146
142
  return arg
147
143
  else
148
144
  return @@arrays[self].values[arg]
149
145
  end
150
146
  end
151
-
147
+
152
148
  def CodeMapper.to_code(arg)
153
149
  if (arg.kind_of?Fixnum)
154
150
  return arg
@@ -156,7 +152,7 @@ module Dnsruby
156
152
  return @@arrays[self].stringsdown[arg.downcase]
157
153
  end
158
154
  end
159
-
155
+
160
156
  def <=>(other)
161
157
  if (other.class == Fixnum)
162
158
  self.code <=> other
@@ -164,7 +160,7 @@ module Dnsruby
164
160
  self.code <=> other.code
165
161
  end
166
162
  end
167
-
163
+
168
164
  def ==(other)
169
165
  return true if [@code, @string].include?other
170
166
  if (CodeMapper === other)
@@ -174,11 +170,11 @@ module Dnsruby
174
170
  end
175
171
  alias eql? == # :nodoc:
176
172
 
177
- # Return a regular expression which matches any codes or strings from the CodeMapper.
173
+ # Return a regular expression which matches any codes or strings from the CodeMapper.
178
174
  def self.regexp
179
- # Longest ones go first, so the regex engine will match AAAA before A, etc.
175
+ # Longest ones go first, so the regex engine will match AAAA before A, etc.
180
176
  return @@arrays[self].strings.keys.sort { |a, b| b.length <=> a.length }.join('|')
181
177
  end
182
-
178
+
183
179
  end
184
180
  end
@@ -0,0 +1,295 @@
1
+ module Dnsruby
2
+
3
+ require 'dnsruby/code_mapper'
4
+
5
+ class OpCode < CodeMapper
6
+ Query = 0 # RFC 1035
7
+ IQuery = 1 # RFC 1035
8
+ Status = 2 # RFC 1035
9
+ Notify = 4 # RFC 1996
10
+ Update = 5 # RFC 2136
11
+
12
+ update()
13
+ end
14
+
15
+ class RCode < CodeMapper
16
+ NOERROR = 0 # RFC 1035
17
+ FORMERR = 1 # RFC 1035
18
+ SERVFAIL = 2 # RFC 1035
19
+ NXDOMAIN = 3 # RFC 1035
20
+ NOTIMP = 4 # RFC 1035
21
+ REFUSED = 5 # RFC 1035
22
+ YXDOMAIN = 6 # RFC 2136
23
+ YXRRSET = 7 # RFC 2136
24
+ NXRRSET = 8 # RFC 2136
25
+ NOTAUTH = 9 # RFC 2136
26
+ NOTZONE = 10 # RFC 2136
27
+
28
+ # BADVERS = 16 # an EDNS ExtendedRCode
29
+ BADSIG = 16
30
+ BADKEY = 17
31
+ BADTIME = 18
32
+ BADMODE = 19
33
+ BADNAME = 20
34
+ BADALG = 21
35
+
36
+ update()
37
+ end
38
+
39
+ class ExtendedRCode < CodeMapper
40
+ BADVERS = 16
41
+ update()
42
+ end
43
+
44
+ class Classes < CodeMapper
45
+ IN = 1 # RFC 1035
46
+ CH = 3 # RFC 1035
47
+ # CHAOS = 3 # RFC 1035
48
+ HS = 4 # RFC 1035
49
+ # HESIOD = 4 # RFC 1035
50
+ NONE = 254 # RFC 2136
51
+ ANY = 255 # RFC 1035
52
+ update()
53
+
54
+ def unknown_string(arg)
55
+ if (arg=~/^CLASS/i)
56
+ Classes.add_pair(arg, arg.gsub('CLASS', '').to_i)
57
+ set_string(arg)
58
+ else
59
+ raise ArgumentError.new("String #{arg} not a member of #{self.class}")
60
+ end
61
+ end
62
+
63
+ def unknown_code(arg)
64
+ Classes.add_pair('CLASS' + arg.to_s, arg)
65
+ set_code(arg)
66
+ end
67
+
68
+ # classesbyval and classesbyname functions are wrappers around the
69
+ # similarly named hashes. They are used for 'unknown' DNS RR classess
70
+ # (RFC3597)
71
+ # See typesbyval and typesbyname, these beasts have the same functionality
72
+ def Classes.classesbyname(name) #:nodoc: all
73
+ name.upcase!;
74
+ if to_code(name)
75
+ return to_code(name)
76
+ end
77
+
78
+ if ((name =~/^\s*CLASS(\d+)\s*$/o) == nil)
79
+ raise ArgumentError, "classesbyval() argument is not CLASS### (#{name})"
80
+ end
81
+
82
+ val = $1.to_i
83
+ if val > 0xffff
84
+ raise ArgumentError, 'classesbyval() argument larger than ' + 0xffff
85
+ end
86
+
87
+ return val;
88
+ end
89
+
90
+
91
+
92
+ def Classes.classesbyval(val) #:nodoc: all
93
+ if (val.class == String)
94
+ if ((val =~ /^\s*0*([0-9]+)\s*$/) == nil)
95
+ raise ArgumentError, "classesbybal() argument is not numeric (#{val})" # unless val.gsub!("^\s*0*([0-9]+)\s*$", "$1")
96
+ # val =~ s/^\s*0*([0-9]+)\s*$/$1/o;#
97
+ end
98
+ val = $1.to_i
99
+ end
100
+
101
+ return to_string(val) if to_string(val)
102
+
103
+ raise ArgumentError, 'classesbyval() argument larger than ' + 0xffff if val > 0xffff;
104
+
105
+ return "CLASS#{val}";
106
+ end
107
+ end
108
+
109
+ # The RR types explicitly supported by Dnsruby.
110
+ #
111
+ # New RR types should be added to this set
112
+ class Types < CodeMapper
113
+ SIGZERO = 0 # RFC2931 consider this a pseudo type
114
+ A = 1 # RFC 1035, Section 3.4.1
115
+ NS = 2 # RFC 1035, Section 3.3.11
116
+ MD = 3 # RFC 1035, Section 3.3.4 (obsolete)
117
+ MF = 4 # RFC 1035, Section 3.3.5 (obsolete)
118
+ CNAME = 5 # RFC 1035, Section 3.3.1
119
+ SOA = 6 # RFC 1035, Section 3.3.13
120
+ MB = 7 # RFC 1035, Section 3.3.3
121
+ MG = 8 # RFC 1035, Section 3.3.6
122
+ MR = 9 # RFC 1035, Section 3.3.8
123
+ NULL = 10 # RFC 1035, Section 3.3.10
124
+ WKS = 11 # RFC 1035, Section 3.4.2 (deprecated)
125
+ PTR = 12 # RFC 1035, Section 3.3.12
126
+ HINFO = 13 # RFC 1035, Section 3.3.2
127
+ MINFO = 14 # RFC 1035, Section 3.3.7
128
+ MX = 15 # RFC 1035, Section 3.3.9
129
+ TXT = 16 # RFC 1035, Section 3.3.14
130
+ RP = 17 # RFC 1183, Section 2.2
131
+ AFSDB = 18 # RFC 1183, Section 1
132
+ X25 = 19 # RFC 1183, Section 3.1
133
+ ISDN = 20 # RFC 1183, Section 3.2
134
+ RT = 21 # RFC 1183, Section 3.3
135
+ NSAP = 22 # RFC 1706, Section 5
136
+ NSAP_PTR = 23 # RFC 1348 (obsolete)
137
+ SIG = 24 # RFC 2535, Section 4.1
138
+ KEY = 25 # RFC 2535, Section 3.1
139
+ PX = 26 # RFC 2163,
140
+ GPOS = 27 # RFC 1712 (obsolete)
141
+ AAAA = 28 # RFC 1886, Section 2.1
142
+ LOC = 29 # RFC 1876
143
+ NXT = 30 # RFC 2535, Section 5.2 obsoleted by RFC3755
144
+ EID = 31 # draft-ietf-nimrod-dns-xx.txt
145
+ NIMLOC = 32 # draft-ietf-nimrod-dns-xx.txt
146
+ SRV = 33 # RFC 2052
147
+ ATMA = 34 # ???
148
+ NAPTR = 35 # RFC 2168
149
+ KX = 36 # RFC 2230
150
+ CERT = 37 # RFC 2538
151
+ DNAME = 39 # RFC 2672
152
+ OPT = 41 # RFC 2671
153
+ # APL = 42 # RFC 3123
154
+ DS = 43 # RFC 4034
155
+ SSHFP = 44 # RFC 4255
156
+ IPSECKEY = 45 # RFC 4025
157
+ RRSIG = 46 # RFC 4034
158
+ NSEC = 47 # RFC 4034
159
+ DNSKEY = 48 # RFC 4034
160
+ DHCID = 49 # RFC 4701
161
+ NSEC3 = 50 # RFC still pending at time of writing
162
+ NSEC3PARAM= 51 # RFC still pending at time of writing
163
+ HIP = 55 # RFC 5205
164
+ SPF = 99 # RFC 4408
165
+ UINFO = 100 # non-standard
166
+ UID = 101 # non-standard
167
+ GID = 102 # non-standard
168
+ UNSPEC = 103 # non-standard
169
+ TKEY = 249 # RFC 2930
170
+ TSIG = 250 # RFC 2931
171
+ IXFR = 251 # RFC 1995
172
+ AXFR = 252 # RFC 1035
173
+ MAILB = 253 # RFC 1035 (MB, MG, MR)
174
+ MAILA = 254 # RFC 1035 (obsolete - see MX)
175
+ ANY = 255 # RFC 1035
176
+ DLV = 32769 # RFC 4431 (informational)
177
+ update()
178
+
179
+ def unknown_string(arg) #:nodoc: all
180
+ if (arg=~/^TYPE/i)
181
+ Types.add_pair(arg, arg.gsub('TYPE', '').to_i)
182
+ set_string(arg)
183
+ else
184
+ raise ArgumentError.new("String #{arg} not a member of #{self.class}")
185
+ end
186
+ end
187
+
188
+ def unknown_code(arg) #:nodoc: all
189
+ Types.add_pair('TYPE' + arg.to_s, arg)
190
+ set_code(arg)
191
+ end
192
+
193
+ # --
194
+ # typesbyval and typesbyname functions are wrappers around the similarly named
195
+ # hashes. They are used for 'unknown' DNS RR types (RFC3597)
196
+ # typesbyname returns they TYPEcode as a function of the TYPE
197
+ # mnemonic. If the TYPE mapping is not specified the generic mnemonic
198
+ # TYPE### is returned.
199
+ def Types.typesbyname(name) #:nodoc: all
200
+ name.upcase!
201
+
202
+ if to_code(name)
203
+ return to_code(name)
204
+ end
205
+
206
+
207
+ if ((name =~/^\s*TYPE(\d+)\s*$/o)==nil)
208
+ raise ArgumentError, "Net::DNS::typesbyname() argument (#{name}) is not TYPE###"
209
+ end
210
+
211
+ val = $1.to_i
212
+ if val > 0xffff
213
+ raise ArgumentError, 'Net::DNS::typesbyname() argument larger than ' + 0xffff
214
+ end
215
+
216
+ return val;
217
+ end
218
+
219
+
220
+ # typesbyval returns they TYPE mnemonic as a function of the TYPE
221
+ # code. If the TYPE mapping is not specified the generic mnemonic
222
+ # TYPE### is returned.
223
+ def Types.typesbyval(val) #:nodoc: all
224
+ if (!defined?val)
225
+ raise ArgumentError, "Net::DNS::typesbyval() argument is not defined"
226
+ end
227
+
228
+ if val.class == String
229
+ # if val.gsub!("^\s*0*(\d+)\s*$", "$1")
230
+ if ((val =~ /^\s*0*(\d+)\s*$", "$1/o) == nil)
231
+ raise ArgumentError, "Net::DNS::typesbyval() argument (#{val}) is not numeric"
232
+ # val =~s/^\s*0*(\d+)\s*$/$1/o;
233
+ end
234
+
235
+ val = $1.to_i
236
+ end
237
+
238
+
239
+ if to_string(val)
240
+ return to_string(val)
241
+ end
242
+
243
+ raise ArgumentError, 'Net::DNS::typesbyval() argument larger than ' + 0xffff if
244
+ val > 0xffff;
245
+
246
+ return "TYPE#{val}";
247
+ end
248
+ end
249
+
250
+ class QTypes < CodeMapper
251
+ IXFR = 251 # incremental transfer [RFC1995]
252
+ AXFR = 252 # transfer of an entire zone [RFC1035]
253
+ MAILB = 253 # mailbox-related RRs (MB, MG or MR) [RFC1035]
254
+ MAILA = 254 # mail agent RRs (Obsolete - see MX) [RFC1035]
255
+ ANY = 255 # all records [RFC1035]
256
+ update()
257
+ end
258
+
259
+ class MetaTypes < CodeMapper
260
+ TKEY = 249 # Transaction Key [RFC2930]
261
+ TSIG = 250 # Transaction Signature [RFC2845]
262
+ OPT = 41 # RFC 2671
263
+ end
264
+
265
+ # http://www.iana.org/assignments/dns-sec-alg-numbers/
266
+ class Algorithms < CodeMapper
267
+ RESERVED = 0
268
+ RSAMD5 = 1
269
+ DH = 2
270
+ DSA = 3
271
+ RSASHA1 = 5
272
+ RSASHA256 = 8
273
+ RSASHA512 = 10
274
+ ECDSAP256SHA256 = 13
275
+ ECDSAP384SHA384 = 14
276
+ INDIRECT = 252
277
+ PRIVATEDNS = 253
278
+ PRIVATEOID = 254
279
+ update()
280
+ # Referred to as Algorithms.DSA_NSEC3_SHA1
281
+ add_pair("DSA-NSEC3-SHA1", 6)
282
+ # Referred to as Algorithms.RSASHA1_NSEC3_SHA1
283
+ add_pair("RSASHA1-NSEC3-SHA1", 7)
284
+ # Referred to as Algorithms.ECC_GOST
285
+ add_pair("ECC-GOST",12)
286
+ end
287
+
288
+ # http://www.iana.org/assignments/dnssec-nsec3-parameters/dnssec-nsec3-parameters.xhtml
289
+ class Nsec3HashAlgorithms < CodeMapper
290
+ RESERVED = 0
291
+ update()
292
+ add_pair("SHA-1", 1)
293
+ end
294
+
295
+ end