use of net.schmizz.sshj.connection.channel.forwarded.RemotePortForwarder 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);
}
use of net.schmizz.sshj.connection.channel.forwarded.RemotePortForwarder in project agileway by fangjinuo.
the class SshjForwardingClient method stopRemoteForwarding.
@Override
public void stopRemoteForwarding(ForwardingChannelInfo channel) throws SshException {
SSHClient delegate = connection.getDelegate();
RemotePortForwarder forwarder = delegate.getRemotePortForwarder();
RemotePortForwarder.Forward forward = new RemotePortForwarder.Forward(channel.getBindingHost(), channel.getBindingPort());
try {
forwarder.cancel(forward);
} catch (Throwable ex) {
throw new SshException(ex);
}
}
Aggregations