diff --git a/src/main/java/ch/ethz/ssh2/Connection.java b/src/main/java/ch/ethz/ssh2/Connection.java index 7367882..a0ffe9f 100644 --- a/src/main/java/ch/ethz/ssh2/Connection.java +++ b/src/main/java/ch/ethz/ssh2/Connection.java @@ -756,7 +756,7 @@ public void run() { /* Wait until first KEX has finished */ - ConnectionInfo ci = tm.getConnectionInfo(1); + ConnectionInfo ci = tm.getConnectionInfo(1, connectTimeout); /* Now try to cancel the timeout, if needed */ @@ -926,7 +926,7 @@ public synchronized int getPort() { public synchronized ConnectionInfo getConnectionInfo() throws IOException { this.checkConnection(); - return tm.getConnectionInfo(1); + return tm.getConnectionInfo(1, 0); } /** diff --git a/src/main/java/ch/ethz/ssh2/ServerConnection.java b/src/main/java/ch/ethz/ssh2/ServerConnection.java index a509157..c7976c9 100644 --- a/src/main/java/ch/ethz/ssh2/ServerConnection.java +++ b/src/main/java/ch/ethz/ssh2/ServerConnection.java @@ -133,7 +133,7 @@ public synchronized void connect(int timeout_milliseconds) throws IOException /* Wait until first KEX has finished */ - state.tm.getConnectionInfo(1); + state.tm.getConnectionInfo(1, timeout_milliseconds); } /** @@ -192,7 +192,7 @@ public synchronized ConnectionInfo getConnectionInfo() throws IOException "Cannot get details of connection, you need to start the key exchange first."); } - return state.tm.getConnectionInfo(1); + return state.tm.getConnectionInfo(1, 0); } /** diff --git a/src/main/java/ch/ethz/ssh2/transport/KexManager.java b/src/main/java/ch/ethz/ssh2/transport/KexManager.java index ccb8f8d..823a2e4 100644 --- a/src/main/java/ch/ethz/ssh2/transport/KexManager.java +++ b/src/main/java/ch/ethz/ssh2/transport/KexManager.java @@ -63,7 +63,7 @@ public KexManager(TransportManager tm, ClientServerHello csh, CryptoWishList ini this.rnd = rnd; } - public ConnectionInfo getOrWaitForConnectionInfo(int minKexCount) throws IOException + public ConnectionInfo getOrWaitForConnectionInfo(int minKexCount, int timeoutMs) throws IOException { synchronized (accessLock) { @@ -77,7 +77,7 @@ public ConnectionInfo getOrWaitForConnectionInfo(int minKexCount) throws IOExcep try { - accessLock.wait(); + accessLock.wait(timeoutMs); } catch (InterruptedException e) { diff --git a/src/main/java/ch/ethz/ssh2/transport/TransportManager.java b/src/main/java/ch/ethz/ssh2/transport/TransportManager.java index e99c199..1224783 100644 --- a/src/main/java/ch/ethz/ssh2/transport/TransportManager.java +++ b/src/main/java/ch/ethz/ssh2/transport/TransportManager.java @@ -165,8 +165,8 @@ public int getPacketOverheadEstimate() { return tc.getPacketOverheadEstimate(); } - public ConnectionInfo getConnectionInfo(int kexNumber) throws IOException { - return km.getOrWaitForConnectionInfo(kexNumber); + public ConnectionInfo getConnectionInfo(int kexNumber, int timeoutMs) throws IOException { + return km.getOrWaitForConnectionInfo(kexNumber, timeoutMs); } public Throwable getReasonClosedCause() {