diff --git a/phpseclib/Net/SSH1.php b/phpseclib/Net/SSH1.php index 84ddba95..8dea0511 100644 --- a/phpseclib/Net/SSH1.php +++ b/phpseclib/Net/SSH1.php @@ -65,7 +65,7 @@ * @author Jim Wigginton * @copyright MMVII Jim Wigginton * @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 */ @@ -384,13 +384,14 @@ class Net_SSH1 { * * @param String $host * @param optional Integer $port + * @param optional Integer $timeout * @param optional Integer $cipher * @return Net_SSH1 * @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) { user_error(rtrim("Cannot connect to $host. Error $errno. $errstr"), E_USER_NOTICE); return; diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index 881f4fef..bc5283ac 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -41,7 +41,7 @@ * @author Jim Wigginton * @copyright MMVII Jim Wigginton * @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 */ @@ -389,13 +389,13 @@ class Net_SSH2 { * * @param String $host * @param optional Integer $port - * @param optional Integer $cipher + * @param optional Integer $timeout * @return Net_SSH2 * @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) { user_error(rtrim("Cannot connect to $host. Error $errno. $errstr"), E_USER_NOTICE); return; @@ -472,10 +472,10 @@ class Net_SSH2 { ); 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-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', // OPTIONAL HMAC-MD5 (digest length = key length = 16) 'none' // OPTIONAL no MAC; NOT RECOMMENDED ); @@ -1237,6 +1237,20 @@ class Net_SSH2 { 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 * @@ -1429,6 +1443,7 @@ class Net_SSH2 { $data = pack('CNNa*Na*', NET_SSH2_MSG_DISCONNECT, $reason, 0, '', 0, ''); $this->_send_binary_packet($data); $this->bitmask = 0; + fclose($this->fsock); return false; }