From a6c0989bc64975e7373fd6a323b505d4c38458b2 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 23 Oct 2014 09:30:46 -0700 Subject: [PATCH] Revert "Merge pull request #4616 from crypt1d/master" This reverts commit aec69c462718a5a506aca6c3d22ff1f34d099510, reversing changes made to 88754d2904ddae53f45172cfe9bf534c8e21c060. --- .../builtin/handle_forwarded_port_collisions.rb | 9 ++++----- .../prepare_forwarded_port_collision_params.rb | 2 +- plugins/providers/virtualbox/driver/version_4_3.rb | 13 ++++++------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb b/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb index 7edb256f3..b53ba35c2 100644 --- a/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb +++ b/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb @@ -92,7 +92,6 @@ module Vagrant with_forwarded_ports(env) do |options| guest_port = options[:guest] host_port = options[:host] - host_ip = options[:host_ip] if options[:protocol] && options[:protocol] != "tcp" @logger.debug("Skipping #{host_port} because UDP protocol.") @@ -106,8 +105,8 @@ module Vagrant end # If the port is open (listening for TCP connections) - in_use = extra_in_use.include?([host_ip,host_port]) || - port_checker[host_ip,host_port] || + in_use = extra_in_use.include?(host_port) || + port_checker[host_port] || lease_check(host_port) if in_use if !repair || !options[:auto_correct] @@ -206,8 +205,8 @@ module Vagrant end end - def port_check(host="127.0.0.1",port) - is_port_open?(host, port) + def port_check(port) + is_port_open?("127.0.0.1", port) end def with_forwarded_ports(env) diff --git a/plugins/providers/virtualbox/action/prepare_forwarded_port_collision_params.rb b/plugins/providers/virtualbox/action/prepare_forwarded_port_collision_params.rb index 0bc1982d5..7fad5ee1e 100644 --- a/plugins/providers/virtualbox/action/prepare_forwarded_port_collision_params.rb +++ b/plugins/providers/virtualbox/action/prepare_forwarded_port_collision_params.rb @@ -14,7 +14,7 @@ module VagrantPlugins # Build the remap for any existing collision detections remap = {} env[:port_collision_remap] = remap - env[:machine].provider.driver.read_forwarded_ports.each do |_nic, name, hostaddr, hostport, _guestport| + env[:machine].provider.driver.read_forwarded_ports.each do |_nic, name, hostport, _guestport| env[:machine].config.vm.networks.each do |type, options| next if type != :forwarded_port diff --git a/plugins/providers/virtualbox/driver/version_4_3.rb b/plugins/providers/virtualbox/driver/version_4_3.rb index 2d8fc6048..70bded802 100644 --- a/plugins/providers/virtualbox/driver/version_4_3.rb +++ b/plugins/providers/virtualbox/driver/version_4_3.rb @@ -18,7 +18,7 @@ module VagrantPlugins def clear_forwarded_ports args = [] - read_forwarded_ports(@uuid).each do |nic, name, _, _, _| + read_forwarded_ports(@uuid).each do |nic, name, _, _| args.concat(["--natpf#{nic}", "delete", name]) end @@ -261,9 +261,8 @@ module VagrantPlugins end # Parse out the forwarded port information - if line =~ /^Forwarding.+?="(.+?),.*?,.(.+?),(.+?),.*?,(.+?)"$/ - result = [current_nic, $1.to_s, $2.to_s, $3.to_i, $4.to_i] - #[["nat", "ssh", "127.0.0.1", 2222, 22]] + if line =~ /^Forwarding.+?="(.+?),.+?,.*?,(.+?),.*?,(.+?)"$/ + result = [current_nic, $1.to_s, $2.to_i, $3.to_i] @logger.debug(" - #{result.inspect}") results << result end @@ -456,8 +455,8 @@ module VagrantPlugins # Ignore our own used ports next if uuid == @uuid - read_forwarded_ports(uuid, true).each do |_, _, hostaddr, hostport, _| - ports << [hostaddr, hostport] + read_forwarded_ports(uuid, true).each do |_, _, hostport, _| + ports << hostport end end end @@ -511,7 +510,7 @@ module VagrantPlugins @logger.debug("Searching for SSH port: #{expected_port.inspect}") # Look for the forwarded port only by comparing the guest port - read_forwarded_ports.each do |_, _, _, hostport, guestport| + read_forwarded_ports.each do |_, _, hostport, guestport| return hostport if guestport == expected_port end