diff --git a/CHANGELOG.md b/CHANGELOG.md index c6af3fe..d0bb17f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ IMPROVEMENTS: - Warn users about unsupported private / public networking configs [#154](https://github.com/fgrehm/vagrant-lxc/issues/154) + - Respect Vagrantfile options to disable forwarded port [#149](https://github.com/fgrehm/vagrant-lxc/issues/149) BUG FIXES: diff --git a/lib/vagrant-lxc/action/forward_ports.rb b/lib/vagrant-lxc/action/forward_ports.rb index dded6e2..5bc4efe 100644 --- a/lib/vagrant-lxc/action/forward_ports.rb +++ b/lib/vagrant-lxc/action/forward_ports.rb @@ -63,6 +63,9 @@ module Vagrant mappings = {} config.vm.networks.each do |type, options| + next if options[:disabled] + + # TODO: Deprecate this behavior of "automagically" skipping ssh forwarded ports if type == :forwarded_port && options[:id] != 'ssh' options.delete(:host_ip) if options.fetch(:host_ip, '').to_s.strip.empty? mappings[options[:host]] = options diff --git a/spec/unit/action/forward_ports_spec.rb b/spec/unit/action/forward_ports_spec.rb index e1fb312..126907e 100644 --- a/spec/unit/action/forward_ports_spec.rb +++ b/spec/unit/action/forward_ports_spec.rb @@ -63,6 +63,13 @@ describe Vagrant::LXC::Action::ForwardPorts do pid_file.should == pid end + it 'allows disabling a previously forwarded port' do + forward_conf[:disabled] = true + subject.stub(system: true) + subject.call(env) + subject.should_not have_received(:spawn) + end + it 'raises RedirNotInstalled error if `redir` is not installed' do subject.stub(system: false) lambda { subject.call(env) }.should raise_error(Vagrant::LXC::Errors::RedirNotInstalled)