Module: Unbound::ResultLayout

Included in:
Result
Defined in:
lib/unbound/result.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

TODO Figure out how to determine version of libunbound and,

thus, proper structure of ub_result


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/unbound/result.rb', line 7

def self.included(base)
  base.class_eval do
    layout( 
           :qname, :string, # char* qname
           :qtype, :int,    # int qtype
           :qclass, :int,   # int qclass

           :data, :pointer, # char** data
           :len,  :pointer, # int* len

           :canonname, :string, # char* canonname

           :rcode, :int, # int rcode

           :answer_packet, :pointer, # void* answer_packet
           :answer_len, :int,        # int answer_len

           :havedata, :int,  # int havedata

           :secure, :int,     # int secure

           :bogus,  :int,       # int bogus
           :why_bogus, :string, # char* why_bogus

           # This wasn't added until unbound version 1.4.20
           #:ttl, :int       # int ttl 
          )

  end
end

Instance Method Details

#answer_packetObject



38
39
40
41
42
43
# File 'lib/unbound/result.rb', line 38

def answer_packet
  if self[:answer_len] <= 0
    return nil
  end
  self[:answer_packet].read_bytes(self[:answer_len])
end

#to_resolvObject



45
46
47
48
49
50
# File 'lib/unbound/result.rb', line 45

def to_resolv
  if ap = answer_packet()
    return Resolv::DNS::Message.decode(ap)
  end
  return nil
end