2013-01-11 23:52:45 +00:00
|
|
|
require "vagrant/util/scoped_hash_override"
|
|
|
|
|
2013-01-11 22:44:27 +00:00
|
|
|
module VagrantPlugins
|
|
|
|
module ProviderVirtualBox
|
|
|
|
module Util
|
|
|
|
module CompileForwardedPorts
|
2013-01-11 23:52:45 +00:00
|
|
|
include Vagrant::Util::ScopedHashOverride
|
|
|
|
|
2013-01-11 22:44:27 +00:00
|
|
|
# This method compiles the forwarded ports into {ForwardedPort}
|
|
|
|
# models.
|
|
|
|
def compile_forwarded_ports(config)
|
|
|
|
mappings = {}
|
|
|
|
|
2013-03-02 00:48:10 +00:00
|
|
|
config.vm.networks.each do |type, options|
|
2013-01-11 22:44:27 +00:00
|
|
|
if type == :forwarded_port
|
2013-03-02 00:48:10 +00:00
|
|
|
guest_port = options[:guest]
|
|
|
|
host_port = options[:host]
|
2016-02-14 11:16:24 +00:00
|
|
|
host_ip = options[:host_ip]
|
2013-08-16 10:10:03 +00:00
|
|
|
protocol = options[:protocol] || "tcp"
|
2013-01-11 23:52:45 +00:00
|
|
|
options = scoped_hash_override(options, :virtualbox)
|
2013-03-02 00:48:10 +00:00
|
|
|
id = options[:id]
|
2013-01-11 22:44:27 +00:00
|
|
|
|
2013-08-29 19:25:53 +00:00
|
|
|
# If the forwarded port was marked as disabled, ignore.
|
|
|
|
next if options[:disabled]
|
|
|
|
|
2016-02-14 11:16:24 +00:00
|
|
|
key = "#{host_ip}#{protocol}#{host_port}"
|
|
|
|
mappings[key] =
|
2013-01-11 22:44:27 +00:00
|
|
|
Model::ForwardedPort.new(id, host_port, guest_port, options)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
mappings.values
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|