Search in sources :

Example 1 with SocketForwardingConnectListener

use of net.schmizz.sshj.connection.channel.forwarded.SocketForwardingConnectListener in project agileway by fangjinuo.

the class SshjForwardingClient method startRemoteForwarding.

@Override
public ForwardingChannelInfo startRemoteForwarding(String bindToHost, int bindToPort, String destHost, int destPort) throws SshException {
    SSHClient delegate = connection.getDelegate();
    RemotePortForwarder forwarder = delegate.getRemotePortForwarder();
    RemotePortForwarder.Forward forward = new RemotePortForwarder.Forward(bindToHost, bindToPort);
    try {
        forwarder.bind(forward, new SocketForwardingConnectListener(new InetSocketAddress(bindToHost, bindToPort)));
    } catch (Throwable ex) {
        throw new SshException(ex);
    }
    return new ForwardingChannelInfo(ForwardingChannelInfo.REMOTE_FORWARDING_CHANNEL, bindToHost, bindToPort, destHost, destPort);
}
Also used : SocketForwardingConnectListener(net.schmizz.sshj.connection.channel.forwarded.SocketForwardingConnectListener) InetSocketAddress(java.net.InetSocketAddress) SSHClient(net.schmizz.sshj.SSHClient) SshException(com.jn.agileway.ssh.client.SshException) ForwardingChannelInfo(com.jn.agileway.ssh.client.channel.forwarding.ForwardingChannelInfo) RemotePortForwarder(net.schmizz.sshj.connection.channel.forwarded.RemotePortForwarder)

Aggregations

SshException (com.jn.agileway.ssh.client.SshException)1 ForwardingChannelInfo (com.jn.agileway.ssh.client.channel.forwarding.ForwardingChannelInfo)1 InetSocketAddress (java.net.InetSocketAddress)1 SSHClient (net.schmizz.sshj.SSHClient)1 RemotePortForwarder (net.schmizz.sshj.connection.channel.forwarded.RemotePortForwarder)1 SocketForwardingConnectListener (net.schmizz.sshj.connection.channel.forwarded.SocketForwardingConnectListener)1