SSH2 / SFTP: fix issues with ping()

This commit is contained in:
terrafrost 2019-09-10 17:31:43 -05:00
parent 3ad44cb3d6
commit fbf36728fd
2 changed files with 23 additions and 4 deletions

View File

@ -465,6 +465,7 @@ class Net_SFTP extends Net_SSH2
function login($username)
{
$args = func_get_args();
$this->auth[] = $args;
if (!call_user_func_array(array(&$this, '_login'), $args)) {
return false;
}
@ -3032,6 +3033,20 @@ class Net_SFTP extends Net_SSH2
return $result;
}
/**
* Resets a connection for re-use
*
* @param int $reason
* @access private
*/
function _reset_connection($reason)
{
parent::_reset_connection($reason);
$this->use_request_id = false;
$this->pwd = false;
$this->requestBuffer = array();
}
/**
* Receives SFTP Packets
*

View File

@ -1238,7 +1238,6 @@ class Net_SSH2
$elapsed = strtok(microtime(), ' ') + strtok('') - $start;
$this->curTimeout-= $elapsed;
}
$temp.= fgets($this->fsock, 255);
}
@ -3243,6 +3242,9 @@ class Net_SSH2
function ping()
{
if (!$this->isAuthenticated()) {
if (!empty($this->auth)) {
return $this->_reconnect();
}
return false;
}
@ -4152,10 +4154,12 @@ class Net_SSH2
if ($this->bitmap & NET_SSH2_MASK_CONNECTED) {
$data = pack('CNNa*Na*', NET_SSH2_MSG_DISCONNECT, $reason, 0, '', 0, '');
$this->_send_binary_packet($data);
$this->bitmap = 0;
fclose($this->fsock);
return false;
}
$this->bitmap = 0;
fclose($this->fsock);
return false;
}
/**