mentochan / ganymed-ssh-2

Automatically exported from code.google.com/p/ganymed-ssh-2
Other
0 stars 0 forks source link

Modify LocalPortForwarder to support ephemeral port identification #24

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When using ch.ethz.ssh2.Connection.createLocalPortForwarder(int local_port, 
String host_to_connect, int port_to_connect), it is possible to specify an 
ephemeral port by using local_port=0.  However, once the socket is bound, there 
is no way to identify what the resulting ephemeral port is.

Example code (based on examples/PortForwarding.java):
------------------
// Create a LocalPortForwarder using an ephemeral port,
// i.e. local_port = 0 means "Choose an open port."
LocalPortForwarder lpf1 = conn.createLocalPortForwarder(0, "www.ethz.ch", 80);

// An ephemeral port has now been created, but there is no way
// to find out what it is.
// netstat -an | grep 
------------------

Proposed API changes:
* Add method to LocalPortForwarder which returns the InetSocketAddress created 
by the ServerSocket.bind(...) call.
-------------
InetSocketAddress LocalPortForwarder.getLocalSocketAddress()
-------------

What version of the product are you using? On what operating system?
* Ganymed-ssh-2 r46 
https://code.google.com/p/ganymed-ssh-2/source/browse/trunk?r=46

* Windows 8 (64-bit)
* OpenJDK 1.6

--------------
$ $JAVA_HOME/bin/java -version
openjdk version "1.6.0-OpenSCG-Build-24"
OpenJDK Runtime Environment (build 1.6.0-OpenSCG-Build-24-b1)
OpenJDK Client VM (build 20.0-b12, mixed mode)
--------------

Original issue reported on code.google.com by joshuaha...@gmail.com on 16 Jul 2013 at 9:15

GoogleCodeExporter commented 9 years ago
See attached diff for implementation of proposed change.

Original comment by joshuaha...@gmail.com on 16 Jul 2013 at 9:17

Attachments:

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Fixed in SVN

Original comment by cleondris on 1 Aug 2013 at 12:41