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 class
RemotePortForwarder.Forward
Represents a particular forwarding.static class
RemotePortForwarder.ForwardedTCPIPChannel
Aforwarded-tcpip
channel.
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<RemotePortForwarder.Forward,ConnectListener>
listeners
protected static java.lang.String
PF_CANCEL
protected static java.lang.String
PF_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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RemotePortForwarder.Forward
bind(RemotePortForwarder.Forward forward, ConnectListener listener)
Request forwarding from the remote host on the specifiedRemotePortForwarder.Forward
.void
cancel(RemotePortForwarder.Forward forward)
Request cancellation of some forwarding.java.util.Set<RemotePortForwarder.Forward>
getActiveForwards()
void
handleOpen(SSHPacket buf)
Internal API.protected SSHPacket
req(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
. Ifforward
specifies as 0, the returned forward will have the correct port number as informed by remote host.- Parameters:
forward
- theRemotePortForwarder.Forward
to put in place on remote hostlistener
- the listener which will next forwarded connection- Returns:
- the
RemotePortForwarder.Forward
which 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.ForwardedTCPIPChannel
from theCHANNEL_OPEN
request and calls associatedConnectListener
for that forward in a separate thread.- Parameters:
buf
-SSHPacket
containing the request except for the message identifier and channel type field- Throws:
ConnectionException
TransportException
-
-