diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index c1105e1a..f5a149db 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -2872,6 +2872,16 @@ class Net_SSH2 return $this->_disconnect(NET_SSH2_DISCONNECT_BY_APPLICATION); } + /** + * Return the currently configured timeout + * + * @return int + */ + function getTimeout() + { + return $this->timeout; + } + /** * Set Timeout * diff --git a/tests/Unit/Net/SSH2UnitTest.php b/tests/Unit/Net/SSH2UnitTest.php index 1c8436b9..a13923fa 100644 --- a/tests/Unit/Net/SSH2UnitTest.php +++ b/tests/Unit/Net/SSH2UnitTest.php @@ -106,6 +106,16 @@ class Unit_Net_SSH2UnitTest extends PhpseclibTestCase $this->assertFalse($ssh->isQuietModeEnabled()); } + public function testGetTimeout() + { + $ssh = new Net_SSH2('localhost'); + $this->assertEquals(10, $ssh->getTimeout()); + $ssh->setTimeout(0); + $this->assertEquals(0, $ssh->getTimeout()); + $ssh->setTimeout(20); + $this->assertEquals(20, $ssh->getTimeout()); + } + /** * @return Net_SSH2 */