Sha256: a07ea6dec1114e529ed3402aa4291af079d42db0c1f55afeeb6cfb11ad660666

Contents?: true

Size: 1.12 KB

Versions: 45

Compression:

Stored size: 1.12 KB

Contents

# NOTE: This has been superseded by sauce/connect. Consider for deprecation

# http://groups.google.com/group/capistrano/browse_thread/thread/455c0c8a6faa9cc8?pli=1
class Net::SSH::Gateway
  # Opens a SSH tunnel from a port on a remote host to a given host and port
  # on the local side
  # (equivalent to openssh -R parameter)
  def open_remote(port, host, remote_port, remote_host = "127.0.0.1")
    ensure_open!

    begin
      @session_mutex.synchronize do
        result = @session.forward.remote(port, host, remote_port, remote_host)
      end
      
      if block_given?
        begin
          yield [remote_port, remote_host]
        ensure
          close_remote(remote_port, remote_host)
        end
      else
        return [remote_port, remote_host]
      end
    rescue Errno::EADDRINUSE
      retry
    end
  end

  # Cancels port-forwarding over an open port that was previously opened via
  # #open_remote.
  def close_remote(port, host = "127.0.0.1")
    puts "Close the remote port #{host}:#{port}!"
    ensure_open!

    @session_mutex.synchronize do
      @session.forward.cancel_remote(port, host)
    end
  end
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
sauce-0.20.0 lib/sauce/gateway_ext.rb
sauce-0.19.1 lib/sauce/gateway_ext.rb
sauce-0.19.0 lib/sauce/gateway_ext.rb
sauce-0.18.3 lib/sauce/gateway_ext.rb
sauce-0.18.2 lib/sauce/gateway_ext.rb
sauce-0.18.1 lib/sauce/gateway_ext.rb
sauce-0.18.0 lib/sauce/gateway_ext.rb
sauce-0.17.8 lib/sauce/gateway_ext.rb
sauce-0.17.7 lib/sauce/gateway_ext.rb
sauce-0.17.6 lib/sauce/gateway_ext.rb
sauce-0.17.5 lib/sauce/gateway_ext.rb
sauce-0.17.4 lib/sauce/gateway_ext.rb
sauce-0.17.3 lib/sauce/gateway_ext.rb
sauce-0.17.3.alpha2 lib/sauce/gateway_ext.rb
sauce-0.17.3.alpha1 lib/sauce/gateway_ext.rb
sauce-0.17.2 lib/sauce/gateway_ext.rb
sauce-0.17.1 lib/sauce/gateway_ext.rb
sauce-0.17.0 lib/sauce/gateway_ext.rb
sauce-0.16.2 lib/sauce/gateway_ext.rb
sauce-0.16.1 lib/sauce/gateway_ext.rb