pssht  latest
SSH server library written in PHP
DISCONNECT.php
1 <?php
2 
3 /*
4 * This file is part of pssht.
5 *
6 * (c) François Poirotte <clicky@erebot.net>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11 
12 namespace fpoirotte\Pssht\Messages;
13 
17 class DISCONNECT extends \Exception implements MessageInterface
18 {
21 
24 
27 
30 
33 
36 
39 
42 
45 
48 
51 
54 
57 
60 
63 
64 
66  protected $code;
67 
69  protected $message;
70 
72  protected $language;
73 
74 
89  public function __construct(
90  $reasonCode = 0,
91  $reasonMessage = '',
92  $language = ''
93  ) {
94  if (!is_int($reasonCode)) {
95  throw new \InvalidArgumentException();
96  }
97  if (!is_string($reasonMessage)) {
98  throw new \InvalidArgumentException();
99  }
100  if (!is_string($language)) {
101  throw new \InvalidArgumentException();
102  }
103 
104  parent::__construct($reasonMessage, $reasonCode);
105  $this->language = $language;
106  }
107 
108  public static function getMessageId()
109  {
110  return 1;
111  }
112 
113  public function serialize(\fpoirotte\Pssht\Wire\Encoder $encoder)
114  {
115  $encoder->encodeUint32($this->code);
116  $encoder->encodeString($this->message);
117  $encoder->encodeString($this->language);
118  return $this;
119  }
120 
121  public static function unserialize(\fpoirotte\Pssht\Wire\Decoder $decoder)
122  {
123  return new static(
124  $decoder->decodeUint32(),
125  $decoder->decodeString(),
126  $decoder->decodeString()
127  );
128  }
129 }
const SSH_DISCONNECT_BY_APPLICATION
Disconnected by the application layer.
Definition: DISCONNECT.php:50
const SSH_DISCONNECT_ILLEGAL_USER_NAME
Disconnected due to an illegal user name.
Definition: DISCONNECT.php:62
const SSH_DISCONNECT_HOST_KEY_NOT_VERIFIABLE
Disconnected due to an unverifiable host key.
Definition: DISCONNECT.php:44
$language
Language the disconnection message is written into (from RFC 3066).
Definition: DISCONNECT.php:72
const SSH_DISCONNECT_SERVICE_NOT_AVAILABLE
Disconnected because the requested service is not available.
Definition: DISCONNECT.php:38
const SSH_DISCONNECT_AUTH_CANCELLED_BY_USER
Disconnected due to authentication cancelation.
Definition: DISCONNECT.php:56
$message
Disconnection message (human-readable description in UTF-8 encoding).
Definition: DISCONNECT.php:69
const SSH_DISCONNECT_CONNECTION_LOST
Disconnected due to connection loss.
Definition: DISCONNECT.php:47
const SSH_DISCONNECT_HOST_NOT_ALLOWED_TO_CONNECT
Disconnected because the remote host is not allowed to connect.
Definition: DISCONNECT.php:20
const SSH_DISCONNECT_KEY_EXCHANGE_FAILED
Disconnected due to key exchange failure.
Definition: DISCONNECT.php:26
const SSH_DISCONNECT_TOO_MANY_CONNECTIONS
Disconnected because too many connections are currently opened.
Definition: DISCONNECT.php:53
const SSH_DISCONNECT_PROTOCOL_ERROR
Disconnected due to a protocol error.
Definition: DISCONNECT.php:23
const SSH_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED
Disconnected due to an unsupported protocol version being requested.
Definition: DISCONNECT.php:41
__construct($reasonCode=0, $reasonMessage= '', $language= '')
Definition: DISCONNECT.php:89
const SSH_DISCONNECT_MAC_ERROR
Disconnected due to a Message Authentication Code error.
Definition: DISCONNECT.php:32
serialize(\fpoirotte\Pssht\Wire\Encoder $encoder)
Definition: DISCONNECT.php:113
const SSH_DISCONNECT_RESERVED
Disconnected due to a reserved error.
Definition: DISCONNECT.php:29
const SSH_DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE
Disconnected because no more authentication methods are available.
Definition: DISCONNECT.php:59
const SSH_DISCONNECT_COMPRESSION_ERROR
Disconnected due to a compression error.
Definition: DISCONNECT.php:35
$code
Disconnection reason.
Definition: DISCONNECT.php:66
static unserialize(\fpoirotte\Pssht\Wire\Decoder $decoder)
Definition: DISCONNECT.php:121