mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-09-28 15:19:02 +00:00
- added $timeout variable
- added destructor to Net_SSH2 git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@12 21d32557-59b3-4da0-833f-c5933fad653e
This commit is contained in:
parent
6101b23a32
commit
81413b9da0
@ -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.5 2007-07-26 14:53:45 terrafrost Exp $
|
* @version $Id: SSH1.php,v 1.6 2008-05-15 16:33:08 terrafrost Exp $
|
||||||
* @link http://phpseclib.sourceforge.net
|
* @link http://phpseclib.sourceforge.net
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -384,13 +384,14 @@ class Net_SSH1 {
|
|||||||
*
|
*
|
||||||
* @param String $host
|
* @param String $host
|
||||||
* @param optional Integer $port
|
* @param optional Integer $port
|
||||||
|
* @param optional Integer $timeout
|
||||||
* @param optional Integer $cipher
|
* @param optional Integer $cipher
|
||||||
* @return Net_SSH1
|
* @return Net_SSH1
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function Net_SSH1($host, $port = 22, $cipher = NET_SSH1_CIPHER_3DES)
|
function Net_SSH1($host, $port = 22, $timeout = 10, $cipher = NET_SSH1_CIPHER_3DES)
|
||||||
{
|
{
|
||||||
$this->fsock = fsockopen($host, $port, $errno, $errstr, 10);
|
$this->fsock = fsockopen($host, $port, $errno, $errstr, $timeout);
|
||||||
if (!$this->fsock) {
|
if (!$this->fsock) {
|
||||||
user_error(rtrim("Cannot connect to $host. Error $errno. $errstr"), E_USER_NOTICE);
|
user_error(rtrim("Cannot connect to $host. Error $errno. $errstr"), E_USER_NOTICE);
|
||||||
return;
|
return;
|
||||||
|
@ -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.3 2007-07-26 14:53:45 terrafrost Exp $
|
* @version $Id: SSH2.php,v 1.4 2008-05-15 16:33:08 terrafrost Exp $
|
||||||
* @link http://phpseclib.sourceforge.net
|
* @link http://phpseclib.sourceforge.net
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -389,13 +389,13 @@ class Net_SSH2 {
|
|||||||
*
|
*
|
||||||
* @param String $host
|
* @param String $host
|
||||||
* @param optional Integer $port
|
* @param optional Integer $port
|
||||||
* @param optional Integer $cipher
|
* @param optional Integer $timeout
|
||||||
* @return Net_SSH2
|
* @return Net_SSH2
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function Net_SSH2($host, $port = 22)
|
function Net_SSH2($host, $port = 22, $timeout = 10)
|
||||||
{
|
{
|
||||||
$this->fsock = fsockopen($host, $port, $errno, $errstr, 10);
|
$this->fsock = fsockopen($host, $port, $errno, $errstr, $timeout);
|
||||||
if (!$this->fsock) {
|
if (!$this->fsock) {
|
||||||
user_error(rtrim("Cannot connect to $host. Error $errno. $errstr"), E_USER_NOTICE);
|
user_error(rtrim("Cannot connect to $host. Error $errno. $errstr"), E_USER_NOTICE);
|
||||||
return;
|
return;
|
||||||
@ -472,10 +472,10 @@ class Net_SSH2 {
|
|||||||
);
|
);
|
||||||
|
|
||||||
static $mac_algorithms = array(
|
static $mac_algorithms = array(
|
||||||
'hmac-sha1', // REQUIRED HMAC-SHA1 (digest length = key length = 20)
|
|
||||||
'hmac-sha1-96', // RECOMMENDED first 96 bits of HMAC-SHA1 (digest length = 12, key length = 20)
|
'hmac-sha1-96', // RECOMMENDED first 96 bits of HMAC-SHA1 (digest length = 12, key length = 20)
|
||||||
'hmac-md5', // OPTIONAL HMAC-MD5 (digest length = key length = 16)
|
'hmac-sha1', // REQUIRED HMAC-SHA1 (digest length = key length = 20)
|
||||||
'hmac-md5-96', // OPTIONAL first 96 bits of HMAC-MD5 (digest length = 12, key length = 16)
|
'hmac-md5-96', // OPTIONAL first 96 bits of HMAC-MD5 (digest length = 12, key length = 16)
|
||||||
|
'hmac-md5', // OPTIONAL HMAC-MD5 (digest length = key length = 16)
|
||||||
'none' // OPTIONAL no MAC; NOT RECOMMENDED
|
'none' // OPTIONAL no MAC; NOT RECOMMENDED
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1237,6 +1237,20 @@ class Net_SSH2 {
|
|||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destructor.
|
||||||
|
*
|
||||||
|
* Will be called, automatically, if you're using PHP5. If you're using PHP4, you'll need to call it yourself.
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function __destruct()
|
||||||
|
{
|
||||||
|
if ($this->bitmap) {
|
||||||
|
$this->_disconnect('Client Quit');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets Binary Packets
|
* Gets Binary Packets
|
||||||
*
|
*
|
||||||
@ -1429,6 +1443,7 @@ class Net_SSH2 {
|
|||||||
$data = pack('CNNa*Na*', NET_SSH2_MSG_DISCONNECT, $reason, 0, '', 0, '');
|
$data = pack('CNNa*Na*', NET_SSH2_MSG_DISCONNECT, $reason, 0, '', 0, '');
|
||||||
$this->_send_binary_packet($data);
|
$this->_send_binary_packet($data);
|
||||||
$this->bitmask = 0;
|
$this->bitmask = 0;
|
||||||
|
fclose($this->fsock);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user