Mercurial > 510Connectbot
diff src/ch/ethz/ssh2/Connection.java @ 290:9ae4ed7bb523 ganymed
start conversion from trilead to ganymed
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Fri, 18 Jul 2014 20:34:21 -0700 |
parents | d2ee20d9dff1 |
children | beaccc9df37b |
line wrap: on
line diff
--- a/src/ch/ethz/ssh2/Connection.java Fri Jul 18 20:17:53 2014 -0700 +++ b/src/ch/ethz/ssh2/Connection.java Fri Jul 18 20:34:21 2014 -0700 @@ -932,6 +932,58 @@ } /** + * Creates a new {@link DynamicPortForwarder}. A + * <code>DynamicPortForwarder</code> forwards TCP/IP connections that arrive + * at a local port via the secure tunnel to another host that is chosen via + * the SOCKS protocol. + * <p> + * This method must only be called after one has passed successfully the + * authentication step. There is no limit on the number of concurrent + * forwardings. + * + * @param local_port + * @return A {@link DynamicPortForwarder} object. + * @throws IOException + */ + + public synchronized DynamicPortForwarder createDynamicPortForwarder(int local_port) throws IOException { + if (tm == null) + throw new IllegalStateException("Cannot forward ports, you need to establish a connection first."); + + if (!authenticated) + throw new IllegalStateException("Cannot forward ports, connection is not authenticated."); + + return new DynamicPortForwarder(cm, local_port); + } + + /** + * Creates a new {@link DynamicPortForwarder}. A + * <code>DynamicPortForwarder</code> forwards TCP/IP connections that arrive + * at a local port via the secure tunnel to another host that is chosen via + * the SOCKS protocol. + * <p> + * This method must only be called after one has passed successfully the + * authentication step. There is no limit on the number of concurrent + * forwardings. + * + * @param addr + * specifies the InetSocketAddress where the local socket shall + * be bound to. + * @return A {@link DynamicPortForwarder} object. + * @throws IOException + */ + + public synchronized DynamicPortForwarder createDynamicPortForwarder(InetSocketAddress addr) throws IOException { + if (tm == null) + throw new IllegalStateException("Cannot forward ports, you need to establish a connection first."); + + if (!authenticated) + throw new IllegalStateException("Cannot forward ports, connection is not authenticated."); + + return new DynamicPortForwarder(cm, addr); + } + + /** * Create a very basic {@link SCPClient} that can be used to copy * files from/to the SSH-2 server. * <p/>