Renamed constants classes

This commit is contained in:
Jack Worman 2022-02-03 12:49:50 -06:00
parent 61f2bc1c06
commit dcf3528c8d
12 changed files with 194 additions and 176 deletions

View File

@ -43,6 +43,7 @@ use phpseclib3\Net\SFTP\OpenFlag;
use phpseclib3\Net\SFTP\OpenFlag5; use phpseclib3\Net\SFTP\OpenFlag5;
use phpseclib3\Net\SFTP\PacketType; use phpseclib3\Net\SFTP\PacketType;
use phpseclib3\Net\SFTP\StatusCode; use phpseclib3\Net\SFTP\StatusCode;
use phpseclib3\Net\Ssh2\MessageType as Ssh2MessageType;
/** /**
* Pure-PHP implementations of SFTP. * Pure-PHP implementations of SFTP.
@ -380,7 +381,7 @@ class SFTP extends SSH2
$packet = Strings::packSSH2( $packet = Strings::packSSH2(
'CsN3', 'CsN3',
SshMsg::CHANNEL_OPEN, Ssh2MessageType::CHANNEL_OPEN,
'session', 'session',
self::CHANNEL, self::CHANNEL,
$this->window_size, $this->window_size,
@ -389,7 +390,7 @@ class SFTP extends SSH2
$this->send_binary_packet($packet); $this->send_binary_packet($packet);
$this->channel_status[self::CHANNEL] = SshMsg::CHANNEL_OPEN; $this->channel_status[self::CHANNEL] = Ssh2MessageType::CHANNEL_OPEN;
$response = $this->get_channel_packet(self::CHANNEL, true); $response = $this->get_channel_packet(self::CHANNEL, true);
if ($response === true && $this->isTimeout()) { if ($response === true && $this->isTimeout()) {
@ -398,7 +399,7 @@ class SFTP extends SSH2
$packet = Strings::packSSH2( $packet = Strings::packSSH2(
'CNsbs', 'CNsbs',
SshMsg::CHANNEL_REQUEST, Ssh2MessageType::CHANNEL_REQUEST,
$this->server_channels[self::CHANNEL], $this->server_channels[self::CHANNEL],
'subsystem', 'subsystem',
true, true,
@ -406,7 +407,7 @@ class SFTP extends SSH2
); );
$this->send_binary_packet($packet); $this->send_binary_packet($packet);
$this->channel_status[self::CHANNEL] = SshMsg::CHANNEL_REQUEST; $this->channel_status[self::CHANNEL] = Ssh2MessageType::CHANNEL_REQUEST;
$response = $this->get_channel_packet(self::CHANNEL, true); $response = $this->get_channel_packet(self::CHANNEL, true);
if ($response === false) { if ($response === false) {
@ -418,7 +419,7 @@ class SFTP extends SSH2
// is redundant // is redundant
$packet = Strings::packSSH2( $packet = Strings::packSSH2(
'CNsCs', 'CNsCs',
SshMsg::CHANNEL_REQUEST, Ssh2MessageType::CHANNEL_REQUEST,
$this->server_channels[self::CHANNEL], $this->server_channels[self::CHANNEL],
'exec', 'exec',
1, 1,
@ -426,7 +427,7 @@ class SFTP extends SSH2
); );
$this->send_binary_packet($packet); $this->send_binary_packet($packet);
$this->channel_status[self::CHANNEL] = SshMsg::CHANNEL_REQUEST; $this->channel_status[self::CHANNEL] = Ssh2MessageType::CHANNEL_REQUEST;
$response = $this->get_channel_packet(self::CHANNEL, true); $response = $this->get_channel_packet(self::CHANNEL, true);
if ($response === false) { if ($response === false) {
@ -436,7 +437,7 @@ class SFTP extends SSH2
return false; return false;
} }
$this->channel_status[self::CHANNEL] = SshMsg::CHANNEL_DATA; $this->channel_status[self::CHANNEL] = Ssh2MessageType::CHANNEL_DATA;
$this->send_sftp_packet(PacketType::INIT, "\0\0\0\3"); $this->send_sftp_packet(PacketType::INIT, "\0\0\0\3");
$response = $this->get_sftp_packet(); $response = $this->get_sftp_packet();
@ -3190,7 +3191,7 @@ class SFTP extends SSH2
while (strlen($this->packet_buffer) < 4) { while (strlen($this->packet_buffer) < 4) {
$temp = $this->get_channel_packet(self::CHANNEL, true); $temp = $this->get_channel_packet(self::CHANNEL, true);
if ($temp === true) { if ($temp === true) {
if ($this->channel_status[self::CHANNEL] === SshMsg::CHANNEL_CLOSE) { if ($this->channel_status[self::CHANNEL] === Ssh2MessageType::CHANNEL_CLOSE) {
$this->channel_close = true; $this->channel_close = true;
} }
$this->packet_type = false; $this->packet_type = false;

View File

@ -3,6 +3,9 @@
namespace phpseclib3\Net\SFTP; namespace phpseclib3\Net\SFTP;
/** /**
* http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-7.1
* the order, in this case, matters quite a lot - see \phpseclib3\Net\SFTP::_parseAttributes() to understand why
*
* @internal * @internal
*/ */
abstract class Attribute abstract class Attribute

View File

@ -3,6 +3,9 @@
namespace phpseclib3\Net\SFTP; namespace phpseclib3\Net\SFTP;
/** /**
* http://tools.ietf.org/html/draft-ietf-secsh-filexfer-04#section-5.2
* see \phpseclib3\Net\SFTP::_parseLongname() for an explanation
*
* @internal * @internal
*/ */
abstract class FileType abstract class FileType

View File

@ -3,6 +3,10 @@
namespace phpseclib3\Net\SFTP; namespace phpseclib3\Net\SFTP;
/** /**
* http://tools.ietf.org/html/draft-ietf-secsh-filexfer-04#section-6.3
* the flag definitions change somewhat in SFTPv5+. if SFTPv5+ support is added to this library, maybe name
* the array for that $this->open5_flags and similarly alter the constant names.
*
* @internal * @internal
*/ */
abstract class OpenFlag abstract class OpenFlag

View File

@ -3,6 +3,8 @@
namespace phpseclib3\Net\SFTP; namespace phpseclib3\Net\SFTP;
/** /**
* SFTPv5+ changed the flags up: https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-13#section-8.1.1.3
*
* @internal * @internal
*/ */
abstract class OpenFlag5 abstract class OpenFlag5

View File

@ -20,7 +20,7 @@ namespace phpseclib3\Net\SFTP;
use phpseclib3\Crypt\Common\PrivateKey; use phpseclib3\Crypt\Common\PrivateKey;
use phpseclib3\Net\SFTP; use phpseclib3\Net\SFTP;
use phpseclib3\Net\SSH2; use phpseclib3\Net\SSH2;
use phpseclib3\Net\SshMsg; use phpseclib3\Net\Ssh2\MessageType as Ssh2MessageType;
/** /**
* SFTP Stream Wrapper * SFTP Stream Wrapper
@ -232,10 +232,10 @@ class Stream
call_user_func($this->notification, STREAM_NOTIFY_CONNECT, STREAM_NOTIFY_SEVERITY_INFO, '', 0, 0, 0); call_user_func($this->notification, STREAM_NOTIFY_CONNECT, STREAM_NOTIFY_SEVERITY_INFO, '', 0, 0, 0);
call_user_func($this->notification, STREAM_NOTIFY_AUTH_REQUIRED, STREAM_NOTIFY_SEVERITY_INFO, '', 0, 0, 0); call_user_func($this->notification, STREAM_NOTIFY_AUTH_REQUIRED, STREAM_NOTIFY_SEVERITY_INFO, '', 0, 0, 0);
if (!$this->sftp->login($user, $pass)) { if (!$this->sftp->login($user, $pass)) {
call_user_func($this->notification, STREAM_NOTIFY_AUTH_RESULT, STREAM_NOTIFY_SEVERITY_ERR, 'Login Failure', SshMsg::USERAUTH_FAILURE, 0, 0); call_user_func($this->notification, STREAM_NOTIFY_AUTH_RESULT, STREAM_NOTIFY_SEVERITY_ERR, 'Login Failure', Ssh2MessageType::USERAUTH_FAILURE, 0, 0);
return false; return false;
} }
call_user_func($this->notification, STREAM_NOTIFY_AUTH_RESULT, STREAM_NOTIFY_SEVERITY_INFO, 'Login Success', SshMsg::USERAUTH_SUCCESS, 0, 0); call_user_func($this->notification, STREAM_NOTIFY_AUTH_RESULT, STREAM_NOTIFY_SEVERITY_INFO, 'Login Success', Ssh2MessageType::USERAUTH_SUCCESS, 0, 0);
} else { } else {
if (!$this->sftp->login($user, $pass)) { if (!$this->sftp->login($user, $pass)) {
return false; return false;

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,11 @@
<?php <?php
namespace phpseclib3\Net; namespace phpseclib3\Net\Ssh2;
/** /**
* @internal * @internal
*/ */
abstract class SshOpen abstract class ChannelConnectionFailureReason
{ {
const ADMINISTRATIVELY_PROHIBITED = 1; const ADMINISTRATIVELY_PROHIBITED = 1;
const CONNECT_FAILED = 2; const CONNECT_FAILED = 2;

View File

@ -1,13 +1,13 @@
<?php <?php
namespace phpseclib3\Net; namespace phpseclib3\Net\Ssh2;
use phpseclib3\Common\ConstantUtilityTrait; use phpseclib3\Common\ConstantUtilityTrait;
/** /**
* @internal * @internal
*/ */
abstract class SshDisconnect abstract class DisconnectReason
{ {
use ConstantUtilityTrait; use ConstantUtilityTrait;

View File

@ -1,13 +1,13 @@
<?php <?php
namespace phpseclib3\Net; namespace phpseclib3\Net\Ssh2;
use phpseclib3\Common\ConstantUtilityTrait; use phpseclib3\Common\ConstantUtilityTrait;
/** /**
* @internal * @internal
*/ */
abstract class SshMsg abstract class MessageType
{ {
use ConstantUtilityTrait; use ConstantUtilityTrait;

View File

@ -1,11 +1,11 @@
<?php <?php
namespace phpseclib3\Net; namespace phpseclib3\Net\Ssh2;
/** /**
* @internal * @internal
*/ */
abstract class SshMsgCustom abstract class MessageTypeExtra
{ {
const KEXDH_INIT = 30; const KEXDH_INIT = 30;
const KEXDH_REPLY = 31; const KEXDH_REPLY = 31;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace phpseclib3\Net; namespace phpseclib3\Net\Ssh2;
/** /**
* @internal * @internal