diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index e414d991..7d68a949 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -2374,6 +2374,16 @@ class SSH2 throw new ConnectionClosedException('Unexpected response to publickey authentication pt 2'); } + /** + * Return the currently configured timeout + * + * @return int + */ + public function getTimeout(): int + { + return $this->timeout; + } + /** * Set Timeout * diff --git a/tests/Unit/Net/SSH2UnitTest.php b/tests/Unit/Net/SSH2UnitTest.php index 59c206fe..3ab39a65 100644 --- a/tests/Unit/Net/SSH2UnitTest.php +++ b/tests/Unit/Net/SSH2UnitTest.php @@ -143,6 +143,16 @@ class SSH2UnitTest extends PhpseclibTestCase $this->assertSame('{' . spl_object_hash($ssh) . '}', $ssh->getResourceId()); } + public function testGetTimeout(): void + { + $ssh = new SSH2('localhost'); + $this->assertEquals(10, $ssh->getTimeout()); + $ssh->setTimeout(0); + $this->assertEquals(0, $ssh->getTimeout()); + $ssh->setTimeout(20); + $this->assertEquals(20, $ssh->getTimeout()); + } + /** */ protected function createSSHMock(): SSH2