Nicely handle nil values for :host_ip when specifying forwarded ports

Fix GH-170
This commit is contained in:
Fabio Rehm 2013-11-06 20:24:24 -02:00
parent f8bd5bf40a
commit c61ade8ef4
3 changed files with 11 additions and 0 deletions

View file

@ -2,6 +2,7 @@
BUG FIXES: 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 - Fix "Permission denied" when starting/destroying containers after lxc
security update in Ubuntu [#180](https://github.com/fgrehm/vagrant-lxc/issues/180) 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) - Fix `vagrant package` [#172](https://github.com/fgrehm/vagrant-lxc/issues/172)

View file

@ -64,6 +64,7 @@ module Vagrant
config.vm.networks.each do |type, options| config.vm.networks.each do |type, options|
if type == :forwarded_port && options[:id] != 'ssh' if type == :forwarded_port && options[:id] != 'ssh'
options.delete(:host_ip) if options.fetch(:host_ip, '').to_s.strip.empty?
mappings[options[:host]] = options mappings[options[:host]] = options
end end
end end

View file

@ -47,6 +47,15 @@ describe Vagrant::LXC::Action::ForwardPorts do
) )
end 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 it "stores redir pids on machine's data dir" do
subject.stub(system: true) subject.stub(system: true)
subject.call(env) subject.call(env)