Class: Radd::DNS

Inherits:
Async::DNS::Server
  • Object
show all
Defined in:
lib/radd/dns.rb

Instance Method Summary collapse

Constructor Details

#initializeDNS

Returns a new instance of DNS.



2
3
4
# File 'lib/radd/dns.rb', line 2

def initialize
  super(Async::DNS::Endpoint.for(Radd.host, port: Radd.dns_port))
end

Instance Method Details

#process(name, resource_class, transaction) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/radd/dns.rb', line 6

def process(name, resource_class, transaction)
  name = name.downcase
  if Resolv::DNS::Resource::IN::A == resource_class
    if Radd.domain == name
      ip = Radd.ip
    else
      ip = Radd.query(name)
    end
  end
  return transaction.respond!(ip, ttl: 300) if ip
  transaction.fail!(:NXDomain)
end