Skip to content

Commit

Permalink
Support for port=0 which means automatically allocated port. (#40)
Browse files Browse the repository at this point in the history
* Support for setting port=0 which means that its automatically allocated, typically from an ephemeral port range

java.net.ServerSocket has support for setting port==0 and will then automatically allocate a port.
trilead.LocalPortForwarder handles this fine however as a user its currently not possible to figure out which port was actually allocated in the end which this fix changes.

* added missing file
  • Loading branch information
Elisedlund-ericsson authored Mar 17, 2020
1 parent 9cbc9c1 commit b9742d8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/com/trilead/ssh2/LocalPortForwarder.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,10 @@ public void close() throws IOException
{
lat.stopWorking();
}

public int getLocalPort()
{
return lat.getLocalPort();
}

}
5 changes: 5 additions & 0 deletions src/com/trilead/ssh2/channel/LocalAcceptThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,9 @@ public void stopWorking()
{
}
}

public int getLocalPort()
{
return ss.getLocalPort();
}
}

0 comments on commit b9742d8

Please sign in to comment.