Top Level Namespace

Defined Under Namespace

Modules: VagrantDns, VagrantDnsServer Classes: Module

Constant Summary collapse

UDNS =
CONF.get('upstream_dns')
UPSTREAM =
RubyDNS::Resolver.new([[:tcp, UDNS, 53], [:udp, UDNS, 53]])
REG =
VagrantDns::Registry.new
CHANNEL =
'vagrant'
RESOLV =
'/etc/resolv.conf'
LOCAL =
"nameserver 127.0.0.1\n"
CONF =
VagrantDns::Configuration.new

Instance Method Summary collapse

Instance Method Details

#atomic_write(path, content) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/vagrant_dns/resolver.rb', line 14

def atomic_write(path, content)
  temp_path = Tempfile.new(path)
  File.open(temp_path, 'w+') do |f|
    f.write(content)
  end
  FileUtils.mv(temp_path, path)
end

#port_open?(ip, port, seconds = 1) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/vagrant_dns/port.rb', line 5

def port_open?(ip, port, seconds=1)
  Timeout::timeout(seconds) do
    begin
	TCPSocket.new(ip, port).close
	true
    rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
	false
    end
  end
rescue Timeout::Error
  false
end