diff --git a/CHANGELOG.md b/CHANGELOG.md index 9937d5f..e005000 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ BUG FIXES: + - Error out in case an invalid IPs are provided for forwarded ports [#170](https://github.com/fgrehm/vagrant-lxc/issues/170) - Fix "Permission denied" when starting/destroying containers after lxc security update in Ubuntu [#180](https://github.com/fgrehm/vagrant-lxc/issues/180) - Fix `vagrant package` [#172](https://github.com/fgrehm/vagrant-lxc/issues/172) diff --git a/lib/vagrant-lxc/action/forward_ports.rb b/lib/vagrant-lxc/action/forward_ports.rb index 9e6199f..dded6e2 100644 --- a/lib/vagrant-lxc/action/forward_ports.rb +++ b/lib/vagrant-lxc/action/forward_ports.rb @@ -64,6 +64,7 @@ module Vagrant config.vm.networks.each do |type, options| if type == :forwarded_port && options[:id] != 'ssh' + options.delete(:host_ip) if options.fetch(:host_ip, '').to_s.strip.empty? mappings[options[:host]] = options end end diff --git a/spec/unit/action/forward_ports_spec.rb b/spec/unit/action/forward_ports_spec.rb index 9ef0e36..e1fb312 100644 --- a/spec/unit/action/forward_ports_spec.rb +++ b/spec/unit/action/forward_ports_spec.rb @@ -47,6 +47,15 @@ describe Vagrant::LXC::Action::ForwardPorts do ) end + it 'skips --laddr parameter if host_ip is a blank string' do + forward_conf[:host_ip] = ' ' + subject.stub(system: true) + subject.call(env) + subject.should have_received(:spawn).with( + "redir --lport=#{host_port} --caddr=#{container_ip} --cport=#{guest_port} 2>/dev/null" + ) + end + it "stores redir pids on machine's data dir" do subject.stub(system: true) subject.call(env)