From 34d00869e5409573b2d2cc264c14570670b1381a Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sun, 5 Mar 2023 01:57:02 -0600 Subject: [PATCH] SSH2: backport getTimeout() --- phpseclib/Net/SSH2.php | 10 ++++++++++ tests/Unit/Net/SSH2UnitTest.php | 10 ++++++++++ 2 files changed, 20 insertions(+) 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 */