Class: DoroParser::DoroDNS
- Inherits:
-
Object
- Object
- DoroParser::DoroDNS
- Defined in:
- lib/dorothy2/DEM.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#cls ⇒ Object
Returns the value of attribute cls.
-
#cls_i ⇒ Object
Returns the value of attribute cls_i.
-
#data ⇒ Object
Returns the value of attribute data.
-
#dns ⇒ Object
Returns the value of attribute dns.
-
#name ⇒ Object
Returns the value of attribute name.
-
#ttl ⇒ Object
Returns the value of attribute ttl.
-
#type ⇒ Object
Returns the value of attribute type.
-
#type_i ⇒ Object
Returns the value of attribute type_i.
Instance Method Summary collapse
-
#initialize(c) ⇒ DoroDNS
constructor
A new instance of DoroDNS.
- #qry? ⇒ Boolean
Constructor Details
#initialize(c) ⇒ DoroDNS
Returns a new instance of DoroDNS.
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
# File 'lib/dorothy2/DEM.rb', line 190 def initialize(c) @dns = Net::DNS::Packet::parse(c) if qry? #is a query q = @dns.question.first @cls_i = q.qClass #Net::DNS::Question.parse(c[12..offset]).qClass @name = q.qName @type_i = q.qType @ttl = 'null' @address = 'null' @data = 'null' elsif !@dns.answer.empty? #contain an asnwer #TODO only the first answer is parsed a = @dns.answer.each.first @ttl = a.ttl @name = a.name @type = a.type @type_i = Net::DNS::RR::Types.new @type @cls = a.cls @cls_i = Net::DNS::RR::Classes.new @cls case @type when "A" @address = @dns.answer.each.first.address @data = 'null' when "AAAA" @address = @dns.answer.each.first.address @data = 'null' when "MX" then @data = @dns.answer.each.first.exchange @address = 'null' when "CNAME" then @data = @dns.answer.each.first.cname @address = 'null' else @address = 'null' @data = 'null' end end end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
187 188 189 |
# File 'lib/dorothy2/DEM.rb', line 187 def address @address end |
#cls ⇒ Object
Returns the value of attribute cls.
185 186 187 |
# File 'lib/dorothy2/DEM.rb', line 185 def cls @cls end |
#cls_i ⇒ Object
Returns the value of attribute cls_i.
186 187 188 |
# File 'lib/dorothy2/DEM.rb', line 186 def cls_i @cls_i end |
#data ⇒ Object
Returns the value of attribute data.
188 189 190 |
# File 'lib/dorothy2/DEM.rb', line 188 def data @data end |
#dns ⇒ Object
Returns the value of attribute dns.
180 181 182 |
# File 'lib/dorothy2/DEM.rb', line 180 def dns @dns end |
#name ⇒ Object
Returns the value of attribute name.
182 183 184 |
# File 'lib/dorothy2/DEM.rb', line 182 def name @name end |
#ttl ⇒ Object
Returns the value of attribute ttl.
181 182 183 |
# File 'lib/dorothy2/DEM.rb', line 181 def ttl @ttl end |
#type ⇒ Object
Returns the value of attribute type.
183 184 185 |
# File 'lib/dorothy2/DEM.rb', line 183 def type @type end |
#type_i ⇒ Object
Returns the value of attribute type_i.
184 185 186 |
# File 'lib/dorothy2/DEM.rb', line 184 def type_i @type_i end |
Instance Method Details
#qry? ⇒ Boolean
246 247 248 |
# File 'lib/dorothy2/DEM.rb', line 246 def qry? @dns.answer.empty? end |