Class: Radd::Nameserver

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

Instance Method Summary collapse

Constructor Details

#initializeNameserver

Returns a new instance of Nameserver.



4
5
6
# File 'lib/radd/nameserver.rb', line 4

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

Instance Method Details

#process(name, resource_class, transaction) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/radd/nameserver.rb', line 8

def process(name, resource_class, transaction)
  name = Resolv::DNS::Name.create(name.downcase)
  type = query_type(resource_class)
  if Radd.origin == name
    case type
    when :A   then return respond_a(transaction, Radd.ip)
    when :SOA then return transaction.respond!(Radd.mname, Radd.rname, Radd.serial, 10800, 1800, 604800, 1800)
    when :NS  then return transaction.respond!(Radd.mname)
    end
  elsif name.subdomain_of?(Radd.origin)
    case type
    when :A then return respond_a(transaction, Radd.query(name))
    when :MX, :AAAA then return transaction.fail!(:NoError)
    end
  end
  transaction.fail!(:Refused)
end