public class

RemotePortForwarder

extends AbstractForwardedChannelOpener
java.lang.Object
   ↳ net.schmizz.sshj.connection.channel.forwarded.AbstractForwardedChannelOpener
     ↳ net.schmizz.sshj.connection.channel.forwarded.RemotePortForwarder

Class Overview

Handles remote port forwarding.

Summary

Nested Classes
class RemotePortForwarder.Forward Represents a particular forwarding. 
class RemotePortForwarder.ForwardedTCPIPChannel A forwarded-tcpip channel. 
Constants
String PF_CANCEL
String PF_REQ
Fields
protected final Map<RemotePortForwarder.ForwardConnectListener> listeners
[Expand]
Inherited Fields
From class net.schmizz.sshj.connection.channel.forwarded.AbstractForwardedChannelOpener
Public Constructors
RemotePortForwarder(Connection conn)
Public Methods
RemotePortForwarder.Forward bind(RemotePortForwarder.Forward forward, ConnectListener listener)
Request forwarding from the remote host on the specified RemotePortForwarder.Forward.
void cancel(RemotePortForwarder.Forward forward)
Request cancellation of some forwarding.
Set<RemotePortForwarder.Forward> getActiveForwards()
void handleOpen(SSHPacket buf)
Internal API.
Protected Methods
SSHPacket req(String reqName, RemotePortForwarder.Forward forward)
[Expand]
Inherited Methods
From class net.schmizz.sshj.connection.channel.forwarded.AbstractForwardedChannelOpener
From class java.lang.Object
From interface net.schmizz.sshj.connection.channel.forwarded.ForwardedChannelOpener

Constants

protected static final String PF_CANCEL

Constant Value: "cancel-tcpip-forward"

protected static final String PF_REQ

Constant Value: "tcpip-forward"

Fields

protected final Map<RemotePortForwarder.ForwardConnectListener> listeners

Public Constructors

public RemotePortForwarder (Connection conn)

Parameters
conn

Public Methods

public RemotePortForwarder.Forward bind (RemotePortForwarder.Forward forward, ConnectListener listener)

Request forwarding from the remote host on the specified RemotePortForwarder.Forward. Forwarded connections will be handled by supplied listener.

If forward specifies as 0, the returned forward will have the correct port number as informed by remote host.

Parameters
forward The RemotePortForwarder.Forward to put in place on remote host
listener The listener which will next forwarded connection
Returns
Throws
ConnectionException if there is an error requesting the forwarding
TransportException

public void cancel (RemotePortForwarder.Forward forward)

Request cancellation of some forwarding.

Parameters
forward The forward which is being cancelled
Throws
ConnectionException if there is an error with the cancellation request
TransportException

public Set<RemotePortForwarder.Forward> getActiveForwards ()

Returns
  • the active forwards.

public void handleOpen (SSHPacket buf)

Internal API. Creates a RemotePortForwarder.ForwardedTCPIPChannel from the CHANNEL_OPEN request and calls associated ConnectListener for that forward in a separate thread.

Parameters
buf

Protected Methods

protected SSHPacket req (String reqName, RemotePortForwarder.Forward forward)

Parameters
reqName
forward