mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-06-03 09:00:52 +00:00
SSH2: set stream timeout before calling stream_get_contents
This commit is contained in:
parent
498e67a0c8
commit
c948a9a407
|
@ -1108,6 +1108,8 @@ class SSH2
|
||||||
* Default Constructor.
|
* Default Constructor.
|
||||||
*
|
*
|
||||||
* $host can either be a string, representing the host, or a stream resource.
|
* $host can either be a string, representing the host, or a stream resource.
|
||||||
|
* If $host is a stream resource then $port doesn't do anything, altho $timeout
|
||||||
|
* still will be used
|
||||||
*
|
*
|
||||||
* @param mixed $host
|
* @param mixed $host
|
||||||
* @param int $port
|
* @param int $port
|
||||||
|
@ -1198,6 +1200,8 @@ class SSH2
|
||||||
31 => 'NET_SSH2_MSG_KEX_ECDH_REPLY')
|
31 => 'NET_SSH2_MSG_KEX_ECDH_REPLY')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->timeout = $timeout;
|
||||||
|
|
||||||
if (is_resource($host)) {
|
if (is_resource($host)) {
|
||||||
$this->fsock = $host;
|
$this->fsock = $host;
|
||||||
return;
|
return;
|
||||||
|
@ -1206,7 +1210,6 @@ class SSH2
|
||||||
if (is_string($host)) {
|
if (is_string($host)) {
|
||||||
$this->host = $host;
|
$this->host = $host;
|
||||||
$this->port = $port;
|
$this->port = $port;
|
||||||
$this->timeout = $timeout;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3646,6 +3649,9 @@ class SSH2
|
||||||
}
|
}
|
||||||
|
|
||||||
$start = microtime(true);
|
$start = microtime(true);
|
||||||
|
$sec = (int) floor($this->curTimeout);
|
||||||
|
$usec = (int) (1000000 * ($this->curTimeout - $sec));
|
||||||
|
stream_set_timeout($this->fsock, $sec, $usec);
|
||||||
$raw = stream_get_contents($this->fsock, $this->decrypt_block_size);
|
$raw = stream_get_contents($this->fsock, $this->decrypt_block_size);
|
||||||
|
|
||||||
if (!strlen($raw)) {
|
if (!strlen($raw)) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user