[DRE-commits] [vagrant-libvirt] 32/163: add gateway_ports option

Antonio Terceiro terceiro at moszumanska.debian.org
Sun Apr 24 13:57:01 UTC 2016


This is an automated email from the git hooks/post-receive script.

terceiro pushed a commit to annotated tag 0.0.26
in repository vagrant-libvirt.

commit a3c10b9e2f7343cf5ab859f9a5869820530d88a8
Author: Adam Spiers <vagrant-libvirt at adamspiers.org>
Date:   Tue Sep 16 18:01:46 2014 +0200

    add gateway_ports option
    
    This allows access to forwarded ports from outside the host.
    Fixes #231.
---
 README.md                                   | 6 ++++++
 lib/vagrant-libvirt/action/forward_ports.rb | 7 +++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 60815be..169617c 100644
--- a/README.md
+++ b/README.md
@@ -309,6 +309,12 @@ vagrant-libvirt supports Forwarded Ports via ssh port forwarding.  For each
 `forwarded_port` directive you specify in your Vagrantfile, vagrant-libvirt
 will maintain an active ssh process for the lifetime of the VM.
 
+vagrant-libvirt supports an additional `forwarded_port` option
+`gateway_ports` which defaults to `false`, but can be set to `true` if
+you want the forwarded port to be accessible from outside the Vagrant
+host.  In this case you should also set the `host_ip` option to `'*'`
+since it defaults to `'localhost'`.
+
 ## Synced Folders
 
 vagrant-libvirt supports bidirectional synced folders via nfs or 9p and
diff --git a/lib/vagrant-libvirt/action/forward_ports.rb b/lib/vagrant-libvirt/action/forward_ports.rb
index 3e52ed7..29de638 100644
--- a/lib/vagrant-libvirt/action/forward_ports.rb
+++ b/lib/vagrant-libvirt/action/forward_ports.rb
@@ -53,7 +53,8 @@ module VagrantPlugins
               fp[:host_ip] || 'localhost',
               fp[:host],
               fp[:guest_ip] || @env[:machine].provider.ssh_info[:host],
-              fp[:guest]
+              fp[:guest],
+              fp[:gateway_ports] || false
             )
             store_ssh_pid(fp[:host], ssh_pid)
           end
@@ -78,13 +79,15 @@ module VagrantPlugins
           mappings.values
         end
 
-        def redirect_port(machine, host_ip, host_port, guest_ip, guest_port)
+        def redirect_port(machine, host_ip, host_port, guest_ip, guest_port,
+                          gateway_ports)
           ssh_info = machine.ssh_info
           params = %W(
             "-L #{host_ip}:#{host_port}:#{guest_ip}:#{guest_port}"
             -N
             #{ssh_info[:host]}
           ).join(' ')
+          params += ' -g' if gateway_ports
 
           options = (%W(
             User=#{ssh_info[:username]}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/vagrant-libvirt.git



More information about the Pkg-ruby-extras-commits mailing list