diff options
author | Kenny Root <kenny@the-b.org> | 2008-11-08 10:01:55 +0000 |
---|---|---|
committer | Kenny Root <kenny@the-b.org> | 2008-11-08 10:01:55 +0000 |
commit | da6d73f5a5818b3cc874f7ed319014d591e101e8 (patch) | |
tree | ba799dfa55a47c77d674af005a77a207de33d0d5 /src/com/trilead/ssh2/Connection.java | |
parent | a15922f44e480a8a6c09741507b1af00d1468d3b (diff) | |
download | connectbot-da6d73f5a5818b3cc874f7ed319014d591e101e8.tar.gz connectbot-da6d73f5a5818b3cc874f7ed319014d591e101e8.tar.bz2 connectbot-da6d73f5a5818b3cc874f7ed319014d591e101e8.zip |
* Add dynamic port forwarding.
Diffstat (limited to 'src/com/trilead/ssh2/Connection.java')
-rw-r--r-- | src/com/trilead/ssh2/Connection.java | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/com/trilead/ssh2/Connection.java b/src/com/trilead/ssh2/Connection.java index 8fbf6fa..2b244c2 100644 --- a/src/com/trilead/ssh2/Connection.java +++ b/src/com/trilead/ssh2/Connection.java @@ -933,6 +933,58 @@ public class Connection }
/**
+ * 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>
|