mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-09-27 22:59:02 +00:00
tweak version management stuff
This commit is contained in:
parent
42b4ab065b
commit
41b5f7cfe9
@ -196,6 +196,15 @@ class Net_SFTP extends Net_SSH2
|
||||
*/
|
||||
var $version;
|
||||
|
||||
/**
|
||||
* Default Server SFTP version
|
||||
*
|
||||
* @var int
|
||||
* @see self::_initChannel()
|
||||
* @access private
|
||||
*/
|
||||
var $defaultVersion;
|
||||
|
||||
/**
|
||||
* Current working directory
|
||||
*
|
||||
@ -609,7 +618,7 @@ class Net_SFTP extends Net_SSH2
|
||||
return false;
|
||||
}
|
||||
extract(unpack('Nversion', $this->_string_shift($response, 4)));
|
||||
$this->version = $version;
|
||||
$this->defaultVersion = $version;
|
||||
while (!empty($response)) {
|
||||
if (strlen($response) < 4) {
|
||||
return false;
|
||||
@ -664,11 +673,12 @@ class Net_SFTP extends Net_SSH2
|
||||
in draft-ietf-secsh-filexfer-13 would be quite impossible. As such, what Net_SFTP would do is close the
|
||||
channel and reopen it with a new and updated SSH_FXP_INIT packet.
|
||||
*/
|
||||
$this->version = $this->defaultVersion;
|
||||
if (isset($this->extensions['versions']) && (!$this->preferredVersion || $this->preferredVersion != $this->version)) {
|
||||
$versions = explode(',', $this->extensions['versions']);
|
||||
$supported = array(6, 5, 4);
|
||||
if ($this->preferredVersion) {
|
||||
$supported = array_diff($supported, [$this->preferredVersion]);
|
||||
$supported = array_diff($supported, array($this->preferredVersion));
|
||||
array_unshift($supported, $this->preferredVersion);
|
||||
}
|
||||
foreach ($supported as $ver) {
|
||||
@ -3624,13 +3634,28 @@ SFTP v6 changes (from v5)
|
||||
$this->_partial_init_sftp_connection();
|
||||
}
|
||||
|
||||
$temp = array('version' => $this->version);
|
||||
$temp = array('version' => $this->defaultVersion);
|
||||
if (isset($this->extensions['versions'])) {
|
||||
$temp['extensions'] = $this->extensions['versions'];
|
||||
}
|
||||
return $temp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get supported SFTP versions
|
||||
*
|
||||
* @return array
|
||||
* @access public
|
||||
*/
|
||||
function getNegotiatedVersion()
|
||||
{
|
||||
if (!$this->_precheck()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set preferred version
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user