lib/chef/provisioning/transport/ssh.rb
# Forwards a port over the connection, and returns the
Forwards a port over the connection, and returns the
Forwards a port over the connection and returns the
def forward_port(local_port, local_host, remote_port, remote_host)
        if session.forward.respond_to?(:active_remote_destinations)
          got_remote_port, remote_host = session.forward.active_remote_destinations[[local_port, local_host]]
          if !got_remote_port
            Chef::Log.debug("Forwarding local server #{local_host}:#{local_port} to #{username}@#{self.host}")
            session.forward.remote(local_port, local_host, remote_port, remote_host) do |actual_remote_port|
              got_remote_port = actual_remote_port || :error
              :no_exception 
            end
            session.loop { !got_remote_port }
            if got_remote_port == :error
              return nil
            end
          end
          [ got_remote_port, remote_host ]
        else
          @forwarded_ports ||= {}
          remote_port, remote_host = @forwarded_ports[[local_port, local_host]]
          if !remote_port
            Chef::Log.debug("Forwarding local server #{local_host}:#{local_port} to #{username}@#{self.host}")
            old_active_remotes = session.forward.active_remotes
            session.forward.remote(local_port, local_host, local_port)
            session.loop { !(session.forward.active_remotes.length > old_active_remotes.length) }
            remote_port, remote_host = (session.forward.active_remotes - old_active_remotes).first
            @forwarded_ports[[local_port, local_host]] = [ remote_port, remote_host ]
          end
          [ remote_port, remote_host ]
        end
      end
def forward_port ( local_port , local_host , remote_port , remote_host ) if session . forward . respond_to? ( :active_remote_destinations ) got_remote_port , remote_host = session . forward . active_remote_destinations [ [ local_port , local_host ] ] if ! got_remote_port Chef :: Log . debug ( "Forwarding local server #{local_host}:#{local_port} to #{username}@#{self.host}" ) session . forward . remote ( local_port , local_host , remote_port , remote_host ) do | actual_remote_port | got_remote_port = actual_remote_port || :error :no_exception end session . loop { ! got_remote_port } if got_remote_port == :error return nil end end [ got_remote_port , remote_host ] else @forwarded_ports ||= { } remote_port , remote_host = @forwarded_ports [ [ local_port , local_host ] ] if ! remote_port Chef :: Log . debug ( "Forwarding local server #{local_host}:#{local_port} to #{username}@#{self.host}" ) old_active_remotes = session . forward . active_remotes session . forward . remote ( local_port , local_host , local_port ) session . loop { ! ( session . forward . active_remotes . length > old_active_remotes . length ) } remote_port , remote_host = ( session . forward . active_remotes - old_active_remotes ) . first @forwarded_ports [ [ local_port , local_host ] ] = [ remote_port , remote_host ] end [ remote_port , remote_host ] end end
Forwards a port over the connection, and returns the
Forwards a port over the connection and returns the
# This bit is from the documentation. # I'll take care of it myself, thanks # Kick SSH until we get a response
local_port
<not_specific>
local_host
<not_specific>
remote_port
<not_specific>
remote_host
<not_specific>