Class: Net::SSH::Service::Forward::Driver

Class | Net::SSH::Service::Forward::Driver
In: | lib/net/ssh/service/forward/driver.rb
Parent: | Object

The Forward::Driver class manages ports that have been forwarded. It will open a socket on each local port and listen for local connections, forwarding those connections over an SSH channel to the other end.

### Methods

active_locals active_remotes cancel_local cancel_remote direct_channel do_open_channel local new remote remote_to

### Attributes

direct_channel_count | [R] | The number of direct (local-to-remote) channels that have been opened.
open_direct_channel_count | [R] | The number of direct (local-to-remote) channels that are currently open.

### Public Class methods

new( connection, buffers, log, handlers )

Create a new Driver instance.

### Public Instance methods

active_locals()

Return an array of the active forwarded local connections. Each element of the array is another array containing the local port, and the remote host and port of the connection.

active_remotes()

Return an array of the active forwarded remote connections. Each element of the array is an integer representing the port number of the remote host that is being forwarded to the local client.

cancel_local( local_port, bind_address="127.0.0.1" )

Cease forwarding connections from the given local port (and interface). The parameters must match those given to a prior call to local. Existing forwarded connections are not affected by this call, but no more connections will be accepted on the local port.

cancel_remote( remote_port, remote_host="127.0.0.1" )

Cease forwarding connections from the given remote port. The `remote_host` parameter must match the corresponding parameter that was passed to remote. Existing forwarded connections are not affected by this call, but no more connections will be forwarded from the remote host to the local host via that port.

direct_channel( local_port, remote_host, remote_port, handler, *data )

Open a direct "tcpip" channel to the remote machine, which will then forward the connection to the given remote-host and remote-port. The connection will appear to have come from the given port on the local machine.

The handler object may respond to the following messages, in order to respond to requests over the channel:

- on_receive( channel, data ): when data is received over the channel (from the remote machine), this method will be invoked.
- on_eof( channel ): when the remote machine will no longer send data, this method will be invoked. The client may continue to send data over the channel, however.
- on_close( channel ): when the channel has been closed and is no longer valid for passing data, this method will be invoked.
- confirm( channel, local_port, remote_host, remote_port, *data ): when the channel has been opened and the remote machine has confirmed it, this method will be invoked. The `data` parameters are the same parameters as were passed to the direct_channel method.
- process( channel ): invoked after the channel is confirmed, to process the channel. It is invoked in a new Thread.

Only the `process` method is required—the others will only be invoked if the handler responds to them.

do_open_channel( connection, channel, data )

open a new channel as requested by the server

local( *args )

Forward connections on the given local port, to the given remote host and remote port.

This method will return immediately, forwarding the connections asynchronously.

remote( handler, remote_port, remote_host="127.0.0.1" )

Initiate forwarding of the given remote port on the connected host. Forwarded packets will be passed to the given block as they are recieved. The remote-host represents the address that should be bound on the remote host, and defaults to ‘127.0.0.1’.

remote_to( port, host, remote_port, remote_host="127.0.0.1" )

A convenience method for setting up a forwarded connection from the given port on the remote host, to the given host and port (local).

[Validate]