Merge pull request #4616 from crypt1d/master
Consider the host_ip value when handling port collisions
This commit is contained in:
commit
aec69c4627
|
@ -92,6 +92,7 @@ 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.")
|
||||
|
@ -105,8 +106,8 @@ module Vagrant
|
|||
end
|
||||
|
||||
# If the port is open (listening for TCP connections)
|
||||
in_use = extra_in_use.include?(host_port) ||
|
||||
port_checker[host_port] ||
|
||||
in_use = extra_in_use.include?([host_ip,host_port]) ||
|
||||
port_checker[host_ip,host_port] ||
|
||||
lease_check(host_port)
|
||||
if in_use
|
||||
if !repair || !options[:auto_correct]
|
||||
|
@ -205,8 +206,8 @@ module Vagrant
|
|||
end
|
||||
end
|
||||
|
||||
def port_check(port)
|
||||
is_port_open?("127.0.0.1", port)
|
||||
def port_check(host="127.0.0.1",port)
|
||||
is_port_open?(host, port)
|
||||
end
|
||||
|
||||
def with_forwarded_ports(env)
|
||||
|
|
|
@ -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, hostport, _guestport|
|
||||
env[:machine].provider.driver.read_forwarded_ports.each do |_nic, name, hostaddr, hostport, _guestport|
|
||||
env[:machine].config.vm.networks.each do |type, options|
|
||||
next if type != :forwarded_port
|
||||
|
||||
|
|
|
@ -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,8 +261,9 @@ module VagrantPlugins
|
|||
end
|
||||
|
||||
# Parse out the forwarded port information
|
||||
if line =~ /^Forwarding.+?="(.+?),.+?,.*?,(.+?),.*?,(.+?)"$/
|
||||
result = [current_nic, $1.to_s, $2.to_i, $3.to_i]
|
||||
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]]
|
||||
@logger.debug(" - #{result.inspect}")
|
||||
results << result
|
||||
end
|
||||
|
@ -455,8 +456,8 @@ module VagrantPlugins
|
|||
# Ignore our own used ports
|
||||
next if uuid == @uuid
|
||||
|
||||
read_forwarded_ports(uuid, true).each do |_, _, hostport, _|
|
||||
ports << hostport
|
||||
read_forwarded_ports(uuid, true).each do |_, _, hostaddr, hostport, _|
|
||||
ports << [hostaddr, hostport]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -510,7 +511,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
|
||||
|
||||
|
|
Loading…
Reference in New Issue