@Override
public SshPortForward forwardLocalPort(InetSocketAddress remoteSocketAddress) throws IOException, SshException {
MinaSshConnectionWrapper sshConnection = ensureConnected();
final ForwardLocalPort forwardLocalPort = new ForwardLocalPort(sshConnection.sshClientSession,
remoteSocketAddress);
forwardLocalPort.start();
return new SshPortForward() {
@Override
public void close() throws IOException {
forwardLocalPort.close();
}
@Override
public InetSocketAddress getLocalSocketAddress() {
return forwardLocalPort.getLocalSocketAddress();
}
};
}