Class: VagrantRubydns::Server
- Inherits:
-
RExec::Daemon::Base
- Object
- RExec::Daemon::Base
- VagrantRubydns::Server
- Defined in:
- lib/vagrant-rubydns/server.rb
Constant Summary collapse
- Name =
Resolv::DNS::Name
- IN =
Resolv::DNS::Resource::IN
Class Method Summary collapse
- .interfaces ⇒ Object
- .pid ⇒ Object
- .port ⇒ Object
- .port=(port) ⇒ Object
- .prefork ⇒ Object
- .run ⇒ Object
- .running? ⇒ Boolean
- .upstream ⇒ Object
- .upstream_servers ⇒ Object
-
.working_directory ⇒ Object
For RExec.
Class Method Details
.interfaces ⇒ Object
20 21 22 23 24 25 |
# File 'lib/vagrant-rubydns/server.rb', line 20 def self.interfaces [ [:udp, "0.0.0.0", port], [:tcp, "0.0.0.0", port] ] end |
.pid ⇒ Object
31 32 33 |
# File 'lib/vagrant-rubydns/server.rb', line 31 def self.pid RExec::Daemon::ProcessFile.recall(self) end |
.port ⇒ Object
8 9 10 |
# File 'lib/vagrant-rubydns/server.rb', line 8 def self.port @port ||= 10053 end |
.port=(port) ⇒ Object
12 13 14 |
# File 'lib/vagrant-rubydns/server.rb', line 12 def self.port=(port) @port = port end |
.prefork ⇒ Object
44 45 46 47 |
# File 'lib/vagrant-rubydns/server.rb', line 44 def self.prefork super ResolverConfig.ensure_config_exists end |
.run ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/vagrant-rubydns/server.rb', line 49 def self.run server = self RubyDNS::run_server(:listen => interfaces) do self.logger.level = Logger::INFO match(/.*/, IN::A) do |transaction| ip = Store.hosts.get(transaction.name) if ip transaction.respond!(ip) else transaction.passthrough!(server.upstream) end end # Default DNS handler otherwise do |transaction| transaction.passthrough!(server.upstream) end end end |
.running? ⇒ Boolean
40 41 42 |
# File 'lib/vagrant-rubydns/server.rb', line 40 def self.running? RExec::Daemon::ProcessFile.status(self) == :running end |
.upstream ⇒ Object
27 28 29 |
# File 'lib/vagrant-rubydns/server.rb', line 27 def self.upstream @upstream ||= RubyDNS::Resolver.new(upstream_servers) end |
.upstream_servers ⇒ Object
16 17 18 |
# File 'lib/vagrant-rubydns/server.rb', line 16 def self.upstream_servers [[:udp, "8.8.8.8", 53], [:tcp, "8.8.8.8", 53]] end |
.working_directory ⇒ Object
For RExec
36 37 38 |
# File 'lib/vagrant-rubydns/server.rb', line 36 def self.working_directory VagrantRubydns.working_dir end |