mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-12-27 19:54:57 +00:00
Merge pull request #229 from bantu/ssh-append-log-intendation
Fix indentation of _append_log in SSH1 and SSH2. * bantu/ssh-append-log-intendation: Fix indentation of _append_log in SSH1 and SSH2.
This commit is contained in:
commit
b793286561
@ -1496,57 +1496,57 @@ class Net_SSH1
|
|||||||
*/
|
*/
|
||||||
function _append_log($protocol_flags, $message)
|
function _append_log($protocol_flags, $message)
|
||||||
{
|
{
|
||||||
switch (NET_SSH1_LOGGING) {
|
switch (NET_SSH1_LOGGING) {
|
||||||
// useful for benchmarks
|
// useful for benchmarks
|
||||||
case NET_SSH1_LOG_SIMPLE:
|
case NET_SSH1_LOG_SIMPLE:
|
||||||
$this->protocol_flags_log[] = $protocol_flags;
|
$this->protocol_flags_log[] = $protocol_flags;
|
||||||
|
break;
|
||||||
|
// the most useful log for SSH1
|
||||||
|
case NET_SSH1_LOG_COMPLEX:
|
||||||
|
$this->protocol_flags_log[] = $protocol_flags;
|
||||||
|
$this->_string_shift($message);
|
||||||
|
$this->log_size+= strlen($message);
|
||||||
|
$this->message_log[] = $message;
|
||||||
|
while ($this->log_size > NET_SSH1_LOG_MAX_SIZE) {
|
||||||
|
$this->log_size-= strlen(array_shift($this->message_log));
|
||||||
|
array_shift($this->protocol_flags_log);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
// dump the output out realtime; packets may be interspersed with non packets,
|
||||||
|
// passwords won't be filtered out and select other packets may not be correctly
|
||||||
|
// identified
|
||||||
|
case NET_SSH1_LOG_REALTIME:
|
||||||
|
echo "<pre>\r\n" . $this->_format_log(array($message), array($protocol_flags)) . "\r\n</pre>\r\n";
|
||||||
|
@flush();
|
||||||
|
@ob_flush();
|
||||||
|
break;
|
||||||
|
// basically the same thing as NET_SSH1_LOG_REALTIME with the caveat that NET_SSH1_LOG_REALTIME_FILE
|
||||||
|
// needs to be defined and that the resultant log file will be capped out at NET_SSH1_LOG_MAX_SIZE.
|
||||||
|
// the earliest part of the log file is denoted by the first <<< START >>> and is not going to necessarily
|
||||||
|
// at the beginning of the file
|
||||||
|
case NET_SSH1_LOG_REALTIME_FILE:
|
||||||
|
if (!isset($this->realtime_log_file)) {
|
||||||
|
// PHP doesn't seem to like using constants in fopen()
|
||||||
|
$filename = NET_SSH1_LOG_REALTIME_FILE;
|
||||||
|
$fp = fopen($filename, 'w');
|
||||||
|
$this->realtime_log_file = $fp;
|
||||||
|
}
|
||||||
|
if (!is_resource($this->realtime_log_file)) {
|
||||||
break;
|
break;
|
||||||
// the most useful log for SSH1
|
}
|
||||||
case NET_SSH1_LOG_COMPLEX:
|
$entry = $this->_format_log(array($message), array($protocol_flags));
|
||||||
$this->protocol_flags_log[] = $protocol_flags;
|
if ($this->realtime_log_wrap) {
|
||||||
$this->_string_shift($message);
|
$temp = "<<< START >>>\r\n";
|
||||||
$this->log_size+= strlen($message);
|
$entry.= $temp;
|
||||||
$this->message_log[] = $message;
|
fseek($this->realtime_log_file, ftell($this->realtime_log_file) - strlen($temp));
|
||||||
while ($this->log_size > NET_SSH1_LOG_MAX_SIZE) {
|
}
|
||||||
$this->log_size-= strlen(array_shift($this->message_log));
|
$this->realtime_log_size+= strlen($entry);
|
||||||
array_shift($this->protocol_flags_log);
|
if ($this->realtime_log_size > NET_SSH1_LOG_MAX_SIZE) {
|
||||||
}
|
fseek($this->realtime_log_file, 0);
|
||||||
break;
|
$this->realtime_log_size = strlen($entry);
|
||||||
// dump the output out realtime; packets may be interspersed with non packets,
|
$this->realtime_log_wrap = true;
|
||||||
// passwords won't be filtered out and select other packets may not be correctly
|
}
|
||||||
// identified
|
fputs($this->realtime_log_file, $entry);
|
||||||
case NET_SSH1_LOG_REALTIME:
|
}
|
||||||
echo "<pre>\r\n" . $this->_format_log(array($message), array($protocol_flags)) . "\r\n</pre>\r\n";
|
|
||||||
@flush();
|
|
||||||
@ob_flush();
|
|
||||||
break;
|
|
||||||
// basically the same thing as NET_SSH1_LOG_REALTIME with the caveat that NET_SSH1_LOG_REALTIME_FILE
|
|
||||||
// needs to be defined and that the resultant log file will be capped out at NET_SSH1_LOG_MAX_SIZE.
|
|
||||||
// the earliest part of the log file is denoted by the first <<< START >>> and is not going to necessarily
|
|
||||||
// at the beginning of the file
|
|
||||||
case NET_SSH1_LOG_REALTIME_FILE:
|
|
||||||
if (!isset($this->realtime_log_file)) {
|
|
||||||
// PHP doesn't seem to like using constants in fopen()
|
|
||||||
$filename = NET_SSH1_LOG_REALTIME_FILE;
|
|
||||||
$fp = fopen($filename, 'w');
|
|
||||||
$this->realtime_log_file = $fp;
|
|
||||||
}
|
|
||||||
if (!is_resource($this->realtime_log_file)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
$entry = $this->_format_log(array($message), array($protocol_flags));
|
|
||||||
if ($this->realtime_log_wrap) {
|
|
||||||
$temp = "<<< START >>>\r\n";
|
|
||||||
$entry.= $temp;
|
|
||||||
fseek($this->realtime_log_file, ftell($this->realtime_log_file) - strlen($temp));
|
|
||||||
}
|
|
||||||
$this->realtime_log_size+= strlen($entry);
|
|
||||||
if ($this->realtime_log_size > NET_SSH1_LOG_MAX_SIZE) {
|
|
||||||
fseek($this->realtime_log_file, 0);
|
|
||||||
$this->realtime_log_size = strlen($entry);
|
|
||||||
$this->realtime_log_wrap = true;
|
|
||||||
}
|
|
||||||
fputs($this->realtime_log_file, $entry);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3006,70 +3006,70 @@ class Net_SSH2
|
|||||||
*/
|
*/
|
||||||
function _append_log($message_number, $message)
|
function _append_log($message_number, $message)
|
||||||
{
|
{
|
||||||
// remove the byte identifying the message type from all but the first two messages (ie. the identification strings)
|
// remove the byte identifying the message type from all but the first two messages (ie. the identification strings)
|
||||||
if (strlen($message_number) > 2) {
|
if (strlen($message_number) > 2) {
|
||||||
$this->_string_shift($message);
|
$this->_string_shift($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (NET_SSH2_LOGGING) {
|
switch (NET_SSH2_LOGGING) {
|
||||||
// useful for benchmarks
|
// useful for benchmarks
|
||||||
case NET_SSH2_LOG_SIMPLE:
|
case NET_SSH2_LOG_SIMPLE:
|
||||||
$this->message_number_log[] = $message_number;
|
$this->message_number_log[] = $message_number;
|
||||||
break;
|
break;
|
||||||
// the most useful log for SSH2
|
// the most useful log for SSH2
|
||||||
case NET_SSH2_LOG_COMPLEX:
|
case NET_SSH2_LOG_COMPLEX:
|
||||||
$this->message_number_log[] = $message_number;
|
$this->message_number_log[] = $message_number;
|
||||||
$this->log_size+= strlen($message);
|
$this->log_size+= strlen($message);
|
||||||
$this->message_log[] = $message;
|
$this->message_log[] = $message;
|
||||||
while ($this->log_size > NET_SSH2_LOG_MAX_SIZE) {
|
while ($this->log_size > NET_SSH2_LOG_MAX_SIZE) {
|
||||||
$this->log_size-= strlen(array_shift($this->message_log));
|
$this->log_size-= strlen(array_shift($this->message_log));
|
||||||
array_shift($this->message_number_log);
|
array_shift($this->message_number_log);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// dump the output out realtime; packets may be interspersed with non packets,
|
// dump the output out realtime; packets may be interspersed with non packets,
|
||||||
// passwords won't be filtered out and select other packets may not be correctly
|
// passwords won't be filtered out and select other packets may not be correctly
|
||||||
// identified
|
// identified
|
||||||
case NET_SSH2_LOG_REALTIME:
|
case NET_SSH2_LOG_REALTIME:
|
||||||
switch (PHP_SAPI) {
|
switch (PHP_SAPI) {
|
||||||
case 'cli':
|
case 'cli':
|
||||||
$start = $stop = "\r\n";
|
$start = $stop = "\r\n";
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$start = '<pre>';
|
|
||||||
$stop = '</pre>';
|
|
||||||
}
|
|
||||||
echo $start . $this->_format_log(array($message), array($message_number)) . $stop;
|
|
||||||
@flush();
|
|
||||||
@ob_flush();
|
|
||||||
break;
|
|
||||||
// basically the same thing as NET_SSH2_LOG_REALTIME with the caveat that NET_SSH2_LOG_REALTIME_FILE
|
|
||||||
// needs to be defined and that the resultant log file will be capped out at NET_SSH2_LOG_MAX_SIZE.
|
|
||||||
// the earliest part of the log file is denoted by the first <<< START >>> and is not going to necessarily
|
|
||||||
// at the beginning of the file
|
|
||||||
case NET_SSH2_LOG_REALTIME_FILE:
|
|
||||||
if (!isset($this->realtime_log_file)) {
|
|
||||||
// PHP doesn't seem to like using constants in fopen()
|
|
||||||
$filename = NET_SSH2_LOG_REALTIME_FILENAME;
|
|
||||||
$fp = fopen($filename, 'w');
|
|
||||||
$this->realtime_log_file = $fp;
|
|
||||||
}
|
|
||||||
if (!is_resource($this->realtime_log_file)) {
|
|
||||||
break;
|
break;
|
||||||
}
|
default:
|
||||||
$entry = $this->_format_log(array($message), array($message_number));
|
$start = '<pre>';
|
||||||
if ($this->realtime_log_wrap) {
|
$stop = '</pre>';
|
||||||
$temp = "<<< START >>>\r\n";
|
}
|
||||||
$entry.= $temp;
|
echo $start . $this->_format_log(array($message), array($message_number)) . $stop;
|
||||||
fseek($this->realtime_log_file, ftell($this->realtime_log_file) - strlen($temp));
|
@flush();
|
||||||
}
|
@ob_flush();
|
||||||
$this->realtime_log_size+= strlen($entry);
|
break;
|
||||||
if ($this->realtime_log_size > NET_SSH2_LOG_MAX_SIZE) {
|
// basically the same thing as NET_SSH2_LOG_REALTIME with the caveat that NET_SSH2_LOG_REALTIME_FILE
|
||||||
fseek($this->realtime_log_file, 0);
|
// needs to be defined and that the resultant log file will be capped out at NET_SSH2_LOG_MAX_SIZE.
|
||||||
$this->realtime_log_size = strlen($entry);
|
// the earliest part of the log file is denoted by the first <<< START >>> and is not going to necessarily
|
||||||
$this->realtime_log_wrap = true;
|
// at the beginning of the file
|
||||||
}
|
case NET_SSH2_LOG_REALTIME_FILE:
|
||||||
fputs($this->realtime_log_file, $entry);
|
if (!isset($this->realtime_log_file)) {
|
||||||
}
|
// PHP doesn't seem to like using constants in fopen()
|
||||||
|
$filename = NET_SSH2_LOG_REALTIME_FILENAME;
|
||||||
|
$fp = fopen($filename, 'w');
|
||||||
|
$this->realtime_log_file = $fp;
|
||||||
|
}
|
||||||
|
if (!is_resource($this->realtime_log_file)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$entry = $this->_format_log(array($message), array($message_number));
|
||||||
|
if ($this->realtime_log_wrap) {
|
||||||
|
$temp = "<<< START >>>\r\n";
|
||||||
|
$entry.= $temp;
|
||||||
|
fseek($this->realtime_log_file, ftell($this->realtime_log_file) - strlen($temp));
|
||||||
|
}
|
||||||
|
$this->realtime_log_size+= strlen($entry);
|
||||||
|
if ($this->realtime_log_size > NET_SSH2_LOG_MAX_SIZE) {
|
||||||
|
fseek($this->realtime_log_file, 0);
|
||||||
|
$this->realtime_log_size = strlen($entry);
|
||||||
|
$this->realtime_log_wrap = true;
|
||||||
|
}
|
||||||
|
fputs($this->realtime_log_file, $entry);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user