- logs now contain timing information

- fixed a potential E_NOTICE error (thanks, Wang Xiaoguang!)


git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@43 21d32557-59b3-4da0-833f-c5933fad653e
This commit is contained in:
Jim Wigginton 2009-08-29 19:23:25 +00:00
parent 5025807abf
commit df8844d12b
2 changed files with 31 additions and 13 deletions

View File

@ -48,7 +48,7 @@
* @author Jim Wigginton <terrafrost@php.net>
* @copyright MMIX Jim Wigginton
* @license http://www.gnu.org/licenses/lgpl.txt
* @version $Id: SFTP.php,v 1.6 2009-08-23 03:40:50 terrafrost Exp $
* @version $Id: SFTP.php,v 1.7 2009-08-29 19:23:25 terrafrost Exp $
* @link http://phpseclib.sourceforge.net
*/
@ -1176,12 +1176,17 @@ class Net_SFTP extends Net_SSH2 {
pack('NCNa*', strlen($data) + 5, $type, $this->request_id, $data) :
pack('NCa*', strlen($data) + 1, $type, $data);
$start = strtok(microtime(), ' ') + strtok(''); // http://php.net/microtime#61838
$result = $this->_send_binary_packet(pack('CN2a*', NET_SSH2_MSG_CHANNEL_DATA, $this->server_channels[$this->client_channel], strlen($data), $data));
$stop = strtok(microtime(), ' ') + strtok('');
if (defined('NET_SFTP_LOGGING')) {
$this->packet_type_log[] = '-> ' . $this->packet_types[$type];
$this->packet_type_log[] = '-> ' . $this->packet_types[$type] .
' (' . round($stop - $start, 4) . 's)';
$this->packet_log[] = $data;
}
return $this->_send_binary_packet(pack('CN2a*', NET_SSH2_MSG_CHANNEL_DATA, $this->server_channels[$this->client_channel], strlen($data), $data));
return $result;
}
/**
@ -1195,6 +1200,8 @@ class Net_SFTP extends Net_SSH2 {
*/
function _get_sftp_packet()
{
$start = strtok(microtime(), ' ') + strtok(''); // http://php.net/microtime#61838
$packet = $this->_get_channel_packet();
if (is_bool($packet)) {
$this->packet_type = false;
@ -1228,8 +1235,11 @@ class Net_SFTP extends Net_SSH2 {
$length-= strlen($temp);
}
$stop = strtok(microtime(), ' ') + strtok('');
if (defined('NET_SFTP_LOGGING')) {
$this->packet_type_log[] = '<- ' . $this->packet_types[$this->packet_type];
$this->packet_type_log[] = '<- ' . $this->packet_types[$this->packet_type] .
' (' . round($stop - $start, 4) . 's)';
$this->packet_log[] = $packet;
}

View File

@ -41,7 +41,7 @@
* @author Jim Wigginton <terrafrost@php.net>
* @copyright MMVII Jim Wigginton
* @license http://www.gnu.org/licenses/lgpl.txt
* @version $Id: SSH2.php,v 1.19 2009-08-23 03:40:50 terrafrost Exp $
* @version $Id: SSH2.php,v 1.20 2009-08-29 19:23:25 terrafrost Exp $
* @link http://phpseclib.sourceforge.net
*/
@ -1212,7 +1212,7 @@ class Net_SSH2 {
$this->debug_info.= "\r\n\r\nSSH_MSG_USERAUTH_PASSWD_CHANGEREQ:\r\n" . utf8_decode($this->_string_shift($response, $length));
return $this->_disconnect(NET_SSH2_DISCONNECT_AUTH_CANCELLED_BY_USER);
case NET_SSH2_MSG_USERAUTH_FAILURE:
list(, $length) = unpack('Nlength', $this->_string_shift($response, 4));
list(, $length) = unpack('N', $this->_string_shift($response, 4));
$this->debug_info.= "\r\n\r\nSSH_MSG_USERAUTH_FAILURE:\r\n" . $this->_string_shift($response, $length);
return $this->_disconnect(NET_SSH2_DISCONNECT_AUTH_CANCELLED_BY_USER);
case NET_SSH2_MSG_USERAUTH_SUCCESS:
@ -1383,7 +1383,9 @@ class Net_SSH2 {
return false;
}
$start = strtok(microtime(), ' ') + strtok(''); // http://php.net/microtime#61838
$raw = fread($this->fsock, $this->decrypt_block_size);
$stop = strtok(microtime(), ' ') + strtok('');
if ($this->decrypt !== false) {
$raw = $this->decrypt->decrypt($raw);
@ -1423,7 +1425,8 @@ class Net_SSH2 {
$this->get_seq_no++;
if (defined('NET_SSH2_LOGGING')) {
$this->message_number_log[] = '<- ' . $this->message_numbers[ord($payload[0])];
$this->message_number_log[] = '-> ' . $this->message_numbers[ord($payload[0])] .
' (' . round($stop - $start, 4) . 's)';
$this->message_log[] = $payload;
}
@ -1599,11 +1602,6 @@ class Net_SSH2 {
return false;
}
if (defined('NET_SSH2_LOGGING')) {
$this->message_number_log[] = '-> ' . $this->message_numbers[ord($data[0])];
$this->message_log[] = $data;
}
//if ($this->compress) {
// // the -4 removes the checksum:
// // http://php.net/function.gzcompress#57710
@ -1634,7 +1632,17 @@ class Net_SSH2 {
$packet.= $hmac;
return strlen($packet) == fputs($this->fsock, $packet);
$start = strtok(microtime(), ' ') + strtok(''); // http://php.net/microtime#61838
$result = strlen($packet) == fputs($this->fsock, $packet);
$stop = strtok(microtime(), ' ') + strtok('');
if (defined('NET_SSH2_LOGGING')) {
$this->message_number_log[] = '-> ' . $this->message_numbers[ord($data[0])] .
' (' . round($stop - $start, 4) . 's)';
$this->message_log[] = $data;
}
return $result;
}
/**