Class: EventMachine::DNSBL::Zone::AbstractZone

Inherits:
Object
  • Object
show all
Defined in:
lib/eventmachine/dnsbl/zone/abstract_zone.rb

Direct Known Subclasses

MemoryZone, Sqlite3Zone

Instance Method Summary collapse

Instance Method Details

#get_records(query, qtype = Resolv::DNS::Resource::IN::A) ⇒ Object



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
# File 'lib/eventmachine/dnsbl/zone/abstract_zone.rb', line 7

def get_records(query, qtype = Resolv::DNS::Resource::IN::A)
  records = Array.new
  # A queries are all that I support right now
  if qtype != Resolv::DNS::Resource::IN::A
    return records
  end

  zone = label = nil
  @zones.each do |z|
    if query.end_with?(z)
      label = query[0, query.length - z.length - 1]
      zone = z
    end
  end
  
  if zone
    get_all_records_for_zone(zone).each do |rec|
      if rec[:valid_until] and rec[:valid_until] < Time.now.to_i
        next
      elsif rec[:label_regex].match(label)
        records << rec
      end
    end
  end
  records
end