Class: VagrantDns::DnsServer

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant_dns/dns.rb

Instance Method Summary collapse

Constructor Details

#initializeDnsServer

Returns a new instance of DnsServer.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/vagrant_dns/dns.rb', line 19

def initialize
	RubyDNS::run_server(:listen => [[:tcp, "localhost", 53],[:udp, "localhost", 53]]) do
	  on(:start) do 
 if ARGV.include?("--debug")
		@logger.level = Logger::DEBUG
 else
		@logger.level = Logger::WARN
 end

	  end

	  otherwise do |transaction|
 ip = REG.read(transaction.name)
 if(ip)
		transaction.respond!(ip)
 else
		begin
transaction.passthrough!(UPSTREAM)
		rescue Exception => e
puts e
		end
 end
	  end
	end
end