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.
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 |
# File 'lib/dorothy2/DEM.rb', line 261 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.
258 259 260 |
# File 'lib/dorothy2/DEM.rb', line 258 def address @address end |
#cls ⇒ Object
Returns the value of attribute cls.
256 257 258 |
# File 'lib/dorothy2/DEM.rb', line 256 def cls @cls end |
#cls_i ⇒ Object
Returns the value of attribute cls_i.
257 258 259 |
# File 'lib/dorothy2/DEM.rb', line 257 def cls_i @cls_i end |
#data ⇒ Object
Returns the value of attribute data.
259 260 261 |
# File 'lib/dorothy2/DEM.rb', line 259 def data @data end |
#dns ⇒ Object
Returns the value of attribute dns.
251 252 253 |
# File 'lib/dorothy2/DEM.rb', line 251 def dns @dns end |
#name ⇒ Object
Returns the value of attribute name.
253 254 255 |
# File 'lib/dorothy2/DEM.rb', line 253 def name @name end |
#ttl ⇒ Object
Returns the value of attribute ttl.
252 253 254 |
# File 'lib/dorothy2/DEM.rb', line 252 def ttl @ttl end |
#type ⇒ Object
Returns the value of attribute type.
254 255 256 |
# File 'lib/dorothy2/DEM.rb', line 254 def type @type end |
#type_i ⇒ Object
Returns the value of attribute type_i.
255 256 257 |
# File 'lib/dorothy2/DEM.rb', line 255 def type_i @type_i end |
Instance Method Details
#qry? ⇒ Boolean
317 318 319 |
# File 'lib/dorothy2/DEM.rb', line 317 def qry? @dns.answer.empty? end |