lib/vagrant_dns/middleware/network_binder.rb in vagrant-dns-server-0.3 vs lib/vagrant_dns/middleware/network_binder.rb in vagrant-dns-server-0.4

- old
+ new

@@ -1,11 +1,11 @@ require 'zmq' module VagrantDns - UI = Vagrant::UI::Colored.new('dns') + UI = Vagrant::UI::Colored.new() class NetworkBinder def bind(vm) (host,ip) = host_ip(vm) Status.new.report(host,ip,:up) end @@ -15,16 +15,16 @@ Status.new.report(host,ip,:down) end private def host_ip(vm) - networks = vm.config.vm.networks.find_all do |type,network_parameters| - type == :hostonly + network = vm.config.vm.networks.find do |type,network_parameters| + type == :private_network end - ips = networks.map {|type,params| params.first} - host = vm.config.vm.host_name - [host,ips.first] + ip = network[1][:ip] + host = vm.config.vm.hostname + [host, ip] end end class Status # if socket is created on middleware initialization vagrant will get stuck @@ -33,10 +33,10 @@ if(port_open?('localhost',url.split(':')[-1])) context = ZMQ::Context.new pub = context.socket(ZMQ::PUB) pub.connect(url) UI.say(:debug,"connection made") - res = pub.send("#{CHANNEL} #{host} #{ip} #{status.to_s}", ZMQ::NOBLOCK) + pub.send("#{CHANNEL} #{host} #{ip} #{status.to_s}", ZMQ::NOBLOCK) UI.say(:info,"notifying dns server with #{status} status") pub.close else UI.say(:debug,"dns server isn't up, skiping notifying #{status} status") end