Class RemotePortForwarder
- java.lang.Object
-
- net.schmizz.sshj.connection.channel.forwarded.AbstractForwardedChannelOpener
-
- net.schmizz.sshj.connection.channel.forwarded.RemotePortForwarder
-
- All Implemented Interfaces:
ForwardedChannelOpener
public class RemotePortForwarder extends AbstractForwardedChannelOpener
Handles remote port forwarding.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRemotePortForwarder.ForwardRepresents a particular forwarding.static classRemotePortForwarder.ForwardedTCPIPChannelAforwarded-tcpipchannel.
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<RemotePortForwarder.Forward,ConnectListener>listenersprotected static java.lang.StringPF_CANCELprotected static java.lang.StringPF_REQ-
Fields inherited from class net.schmizz.sshj.connection.channel.forwarded.AbstractForwardedChannelOpener
chanType, conn, log
-
-
Constructor Summary
Constructors Constructor Description RemotePortForwarder(Connection conn)
-
Method Summary
Modifier and Type Method Description RemotePortForwarder.Forwardbind(RemotePortForwarder.Forward forward, ConnectListener listener)Request forwarding from the remote host on the specifiedRemotePortForwarder.Forward.voidcancel(RemotePortForwarder.Forward forward)Request cancellation of some forwarding.java.util.Set<RemotePortForwarder.Forward>getActiveForwards()voidhandleOpen(SSHPacket buf)Internal API.protected SSHPacketreq(java.lang.String reqName, RemotePortForwarder.Forward forward)-
Methods inherited from class net.schmizz.sshj.connection.channel.forwarded.AbstractForwardedChannelOpener
callListener, getChannelType
-
-
-
-
Field Detail
-
PF_REQ
protected static final java.lang.String PF_REQ
- See Also:
- Constant Field Values
-
PF_CANCEL
protected static final java.lang.String PF_CANCEL
- See Also:
- Constant Field Values
-
listeners
protected final java.util.Map<RemotePortForwarder.Forward,ConnectListener> listeners
-
-
Constructor Detail
-
RemotePortForwarder
public RemotePortForwarder(Connection conn)
-
-
Method Detail
-
bind
public RemotePortForwarder.Forward bind(RemotePortForwarder.Forward forward, ConnectListener listener) throws ConnectionException, TransportException
Request forwarding from the remote host on the specifiedRemotePortForwarder.Forward. Forwarded connections will be handled by suppliedlistener. Ifforwardspecifies as 0, the returned forward will have the correct port number as informed by remote host.- Parameters:
forward- theRemotePortForwarder.Forwardto put in place on remote hostlistener- the listener which will next forwarded connection- Returns:
- the
RemotePortForwarder.Forwardwhich was put into place on the remote host - Throws:
ConnectionException- if there is an error requesting the forwardingTransportException
-
cancel
public void cancel(RemotePortForwarder.Forward forward) throws ConnectionException, TransportException
Request cancellation of some forwarding.- Parameters:
forward- the forward which is being cancelled- Throws:
ConnectionException- if there is an error with the cancellation requestTransportException
-
req
protected SSHPacket req(java.lang.String reqName, RemotePortForwarder.Forward forward) throws ConnectionException, TransportException
-
getActiveForwards
public java.util.Set<RemotePortForwarder.Forward> getActiveForwards()
- Returns:
- the active forwards.
-
handleOpen
public void handleOpen(SSHPacket buf) throws ConnectionException, TransportException
Internal API. Creates aRemotePortForwarder.ForwardedTCPIPChannelfrom theCHANNEL_OPENrequest and calls associatedConnectListenerfor that forward in a separate thread.- Parameters:
buf-SSHPacketcontaining the request except for the message identifier and channel type field- Throws:
ConnectionExceptionTransportException
-
-