diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index abad3eb7..4984156b 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -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 * diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index 680e3c2b..d7124041 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -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; } /**