Class: Explorer::Server::DNS

Inherits:
RubyDNS::Server
  • Object
show all
Defined in:
lib/explorer/server/dns.rb

Instance Method Summary collapse

Constructor Details

#initialize(port) ⇒ DNS

Returns a new instance of DNS.



6
7
8
9
# File 'lib/explorer/server/dns.rb', line 6

def initialize(port)
  super listen: interfaces(port)
  async.run
end

Instance Method Details

#process(name, resource_class, transaction) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/explorer/server/dns.rb', line 11

def process(name, resource_class, transaction)
  return transaction.fail!(:NXDomain) unless name_matches?(name)

  if resource_class == Resolv::DNS::Resource::IN::A
    transaction.respond!('127.0.0.1')
  elsif resource_class == Resolv::DNS::Resource::IN::AAAA
    transaction.respond!('::1')
  else
    transaction.fail!(:NXDomain)
  end
end