1
0
mirror of https://github.com/danog/phpseclib.git synced 2025-01-22 04:51:19 +01:00

*** empty log message ***

git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@13 21d32557-59b3-4da0-833f-c5933fad653e
This commit is contained in:
Jim Wigginton 2008-05-15 17:40:03 +00:00
parent 81413b9da0
commit 148178da63
2 changed files with 50 additions and 15 deletions

View File

@ -65,7 +65,7 @@
* @author Jim Wigginton <terrafrost@php.net> * @author Jim Wigginton <terrafrost@php.net>
* @copyright MMVII Jim Wigginton * @copyright MMVII Jim Wigginton
* @license http://www.gnu.org/licenses/lgpl.txt * @license http://www.gnu.org/licenses/lgpl.txt
* @version $Id: SSH1.php,v 1.6 2008-05-15 16:33:08 terrafrost Exp $ * @version $Id: SSH1.php,v 1.7 2008-05-15 17:40:03 terrafrost Exp $
* @link http://phpseclib.sourceforge.net * @link http://phpseclib.sourceforge.net
*/ */
@ -764,16 +764,40 @@ class Net_SSH1 {
} }
/** /**
* Disconnects. * Disconnect
* *
* Will be called, automatically, if you're using PHP5. If you're using PHP4, call it yourself. * @access public
*/
function disconnect()
{
$this->_disconnect();
}
/**
* Destructor.
*
* Will be called, automatically, if you're supporting just PHP5. If you're supporting PHP4, you'll need to call
* disconnect().
* *
* @access public * @access public
*/ */
function __destruct() function __destruct()
{
$this->_disconnect();
}
/**
* Gets Binary Packets
*
* See '6. Binary Packet Protocol' of rfc4253 for more info.
*
* @see Net_SSH2::_send_binary_packet()
* @return String
* @access private
*/
function _disconnect($msg = 'Client Quit')
{ {
if ($this->bitmap) { if ($this->bitmap) {
$msg = 'Client Quit';
$data = pack('CNa*', NET_SSH1_MSG_DISCONNECT, strlen($msg), $msg); $data = pack('CNa*', NET_SSH1_MSG_DISCONNECT, strlen($msg), $msg);
$this->_send_binary_packet($data); $this->_send_binary_packet($data);
fclose($this->fsock); fclose($this->fsock);

View File

@ -41,7 +41,7 @@
* @author Jim Wigginton <terrafrost@php.net> * @author Jim Wigginton <terrafrost@php.net>
* @copyright MMVII Jim Wigginton * @copyright MMVII Jim Wigginton
* @license http://www.gnu.org/licenses/lgpl.txt * @license http://www.gnu.org/licenses/lgpl.txt
* @version $Id: SSH2.php,v 1.4 2008-05-15 16:33:08 terrafrost Exp $ * @version $Id: SSH2.php,v 1.5 2008-05-15 17:40:03 terrafrost Exp $
* @link http://phpseclib.sourceforge.net * @link http://phpseclib.sourceforge.net
*/ */
@ -1237,18 +1237,27 @@ class Net_SSH2 {
return $output; return $output;
} }
/**
* Disconnect
*
* @access public
*/
function disconnect()
{
$this->_disconnect(NET_SSH2_DISCONNECT_BY_APPLICATION);
}
/** /**
* Destructor. * Destructor.
* *
* Will be called, automatically, if you're using PHP5. If you're using PHP4, you'll need to call it yourself. * Will be called, automatically, if you're supporting just PHP5. If you're supporting PHP4, you'll need to call
* disconnect().
* *
* @access public * @access public
*/ */
function __destruct() function __destruct()
{ {
if ($this->bitmap) { $this->disconnect();
$this->_disconnect('Client Quit');
}
} }
/** /**
@ -1398,7 +1407,7 @@ class Net_SSH2 {
function _send_binary_packet($data) function _send_binary_packet($data)
{ {
if (feof($this->fsock)) { if (feof($this->fsock)) {
user_error('Connection closed prematurely', E_USERe_NOTICE); user_error('Connection closed prematurely', E_USER_NOTICE);
return false; return false;
} }
@ -1440,11 +1449,13 @@ class Net_SSH2 {
*/ */
function _disconnect($reason) function _disconnect($reason)
{ {
$data = pack('CNNa*Na*', NET_SSH2_MSG_DISCONNECT, $reason, 0, '', 0, ''); if ($this->bitmap) {
$this->_send_binary_packet($data); $data = pack('CNNa*Na*', NET_SSH2_MSG_DISCONNECT, $reason, 0, '', 0, '');
$this->bitmask = 0; $this->_send_binary_packet($data);
fclose($this->fsock); $this->bitmask = 0;
return false; fclose($this->fsock);
return false;
}
} }
/** /**