Package org.apache.sshd.common.forward
Class ChannelToPortHandler
- java.lang.Object
-
- org.apache.sshd.common.util.logging.AbstractLoggingBean
-
- org.apache.sshd.common.forward.ChannelToPortHandler
-
public class ChannelToPortHandler extends AbstractLoggingBean
Implements forwarding messages received from a channel to a port in TCP/IP port forwarding.
-
-
Constructor Summary
Constructors Constructor Description ChannelToPortHandler(IoSession port, Channel channel)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcheckWindow(byte cmd, long len)IoSessiongetPortSession()Retrieves theIoSessionfor the port connection.voidhandleEof()Perform appropriate actions on the port session when the channel received an SSH_MSG_CHANNEL_EOF message.protected voidhandleWriteDataFailure(byte cmd, byte[] data, int off, int len, java.lang.Throwable t)protected voidhandleWriteDataSuccess(byte cmd, byte[] data, int off, int len)voidsendToPort(byte cmd, byte[] data, int off, long len)Forwards data received on the SSH channel to the port and adjust the channel window once the data has been written.IoWriteFuturesendToPort(Buffer buffer)Write data to the port directly without adjusting the channel window.
-
-
-
Method Detail
-
getPortSession
public IoSession getPortSession()
Retrieves theIoSessionfor the port connection.- Returns:
- the
IoSession, nevernull
-
handleEof
public void handleEof() throws java.io.IOExceptionPerform appropriate actions on the port session when the channel received an SSH_MSG_CHANNEL_EOF message.- Throws:
java.io.IOException
-
sendToPort
public IoWriteFuture sendToPort(Buffer buffer) throws java.io.IOException
Write data to the port directly without adjusting the channel window.- Parameters:
buffer- data to write to the port- Returns:
- an
IoWriteFuturefulfilled once the data has been written - Throws:
java.io.IOException- if an error occurs
-
sendToPort
public void sendToPort(byte cmd, byte[] data, int off, long len) throws java.io.IOExceptionForwards data received on the SSH channel to the port and adjust the channel window once the data has been written.- Parameters:
cmd- the SSH command, typically @link SshConstants#SSH_MSG_CHANNEL_DATA}, used for logging onlydata- to forwardoff- offset indataof the start of the data to forwardlen- number of bytes to forward- Throws:
java.io.IOException- if an error occurs
-
handleWriteDataSuccess
protected void handleWriteDataSuccess(byte cmd, byte[] data, int off, int len)
-
handleWriteDataFailure
protected void handleWriteDataFailure(byte cmd, byte[] data, int off, int len, java.lang.Throwable t)
-
checkWindow
private void checkWindow(byte cmd, long len)
-
-