Error if forwarded port with same host port is declared multiple times
This commit is contained in:
parent
f03175b4af
commit
6e7427ca4d
|
@ -4,6 +4,8 @@ IMPROVEMENTS:
|
||||||
|
|
||||||
- Don't load plugins on any `vagrant plugin` command, so that errors
|
- Don't load plugins on any `vagrant plugin` command, so that errors
|
||||||
are avoided. [GH-1418]
|
are avoided. [GH-1418]
|
||||||
|
- An error will be shown if you forward a port to the same host port
|
||||||
|
multiple times.
|
||||||
|
|
||||||
BUG FIXES:
|
BUG FIXES:
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
require "pathname"
|
require "pathname"
|
||||||
require "securerandom"
|
require "securerandom"
|
||||||
|
require "set"
|
||||||
|
|
||||||
require "vagrant"
|
require "vagrant"
|
||||||
require "vagrant/config/v2/util"
|
require "vagrant/config/v2/util"
|
||||||
|
@ -277,12 +278,23 @@ module VagrantPlugins
|
||||||
|
|
||||||
# Validate networks
|
# Validate networks
|
||||||
has_fp_port_error = false
|
has_fp_port_error = false
|
||||||
|
fp_host_ports = Set.new
|
||||||
|
|
||||||
networks.each do |type, options|
|
networks.each do |type, options|
|
||||||
if type == :forwarded_port
|
if type == :forwarded_port
|
||||||
if !has_fp_port_error && (!options[:guest] || !options[:host])
|
if !has_fp_port_error && (!options[:guest] || !options[:host])
|
||||||
errors << I18n.t("vagrant.config.vm.network_fp_requires_ports")
|
errors << I18n.t("vagrant.config.vm.network_fp_requires_ports")
|
||||||
has_fp_port_error = true
|
has_fp_port_error = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if options[:host]
|
||||||
|
if fp_host_ports.include?(options[:host])
|
||||||
|
errors << I18n.t("vagrant.config.vm.network_fp_host_not_unique",
|
||||||
|
:host => options[:host].to_s)
|
||||||
|
end
|
||||||
|
|
||||||
|
fp_host_ports.add(options[:host])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -456,6 +456,8 @@ en:
|
||||||
nfs_requires_host: |-
|
nfs_requires_host: |-
|
||||||
Using NFS shared folders requires a host to be specified
|
Using NFS shared folders requires a host to be specified
|
||||||
using `config.vagrant.host`.
|
using `config.vagrant.host`.
|
||||||
|
network_fp_host_not_unique: |-
|
||||||
|
Forwarded port '%{host}' (host port) is declared multiple times
|
||||||
network_fp_requires_ports: |-
|
network_fp_requires_ports: |-
|
||||||
Forwarded port definitions require a "host" and "guest" value
|
Forwarded port definitions require a "host" and "guest" value
|
||||||
shared_folder_hostpath_missing: |-
|
shared_folder_hostpath_missing: |-
|
||||||
|
|
Loading…
Reference in New Issue