Example #1
0
 /**
  * Starts a local to remote port forwarding (the equivalent of "ssh -L").
  *
  * @param recvPort The port on this local machine that we'll listen to. 0 to let OS pick a random
  *     available port. If you specify 0, use {@link ListeningPort#getPort()} to figure out the
  *     actual assigned port.
  * @param forwardHost The remote host that the connection will be forwarded to. Connection to this
  *     host will be made from the other JVM that this {@link Channel} represents.
  * @param forwardPort The remote port that the connection will be forwarded to.
  * @return
  */
 public ListeningPort createLocalToRemotePortForwarding(
     int recvPort, String forwardHost, int forwardPort) throws IOException, InterruptedException {
   PortForwarder portForwarder =
       new PortForwarder(recvPort, ForwarderFactory.create(this, forwardHost, forwardPort));
   portForwarder.start();
   return portForwarder;
 }
Example #2
0
 /**
  * Starts a remote to local port forwarding (the equivalent of "ssh -R").
  *
  * @param recvPort The port on the remote JVM (represented by this {@link Channel}) that we'll
  *     listen to. 0 to let OS pick a random available port. If you specify 0, use {@link
  *     ListeningPort#getPort()} to figure out the actual assigned port.
  * @param forwardHost The remote host that the connection will be forwarded to. Connection to this
  *     host will be made from this JVM.
  * @param forwardPort The remote port that the connection will be forwarded to.
  * @return
  */
 public ListeningPort createRemoteToLocalPortForwarding(
     int recvPort, String forwardHost, int forwardPort) throws IOException, InterruptedException {
   return PortForwarder.create(this, recvPort, ForwarderFactory.create(forwardHost, forwardPort));
 }