diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index a248c258..074b4f7f 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -410,6 +410,7 @@ class SFTP extends SSH2 function login($username) { $args = func_get_args(); + $this->auth[] = $args; if (!call_user_func_array(array(&$this, '_login'), $args)) { return false; } @@ -2975,6 +2976,20 @@ class SFTP extends 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 78a587ff..7c2c8565 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -3206,6 +3206,9 @@ class SSH2 function ping() { if (!$this->isAuthenticated()) { + if (!empty($this->auth)) { + return $this->_reconnect(); + } return false; } @@ -4113,10 +4116,12 @@ class SSH2 if ($this->bitmap & self::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; } /**