Fix empty log files in the GUI. Fixes #9415

Two ways they were empty that I found:
* filterlog log entries now have a pid after the process
* CARP/VRRP entries did not set a source and so were not logged

While here, add CARP details to proto field of GUI log view.
This commit is contained in:
jim-p 2019-03-20 16:19:57 -04:00
parent f30da999bc
commit af85efec3a
2 changed files with 18 additions and 2 deletions

View File

@ -83,7 +83,7 @@ function conv_log_filter($logfile, $nentries, $tail = 50, $filtertext = "", $fil
# Construct RegEx for specific log file type.
if ($logfile_type == 'firewall') {
$pattern = "filterlog:";
$pattern = "filterlog";
}
else if ($logfile_type == 'system') {
$pattern = "^" . $date_pattern . "\ +" . $host_pattern . "\ +" . $process_pid_pattern . "\ +" . $log_message_pattern . "$";
@ -303,7 +303,7 @@ function parse_firewall_log_line($line) {
$flent = array();
$log_split = "";
if (!preg_match("/(.*)\s(.*)\sfilterlog:\s(.*)$/", $line, $log_split)) {
if (!preg_match("/(.*)\s(.*)\sfilterlog\[[0-9]+\]:\s(.*)$/", $line, $log_split)) {
return "";
}
@ -419,6 +419,8 @@ function parse_firewall_log_line($line) {
$flent['version'] = $rule_data[$field++];
$flent['advskew'] = $rule_data[$field++];
$flent['advbase'] = $rule_data[$field++];
$flent['src'] = $flent['srcip'];
$flent['dst'] = $flent['dstip'];
}
} else {
if ($g['debug']) {

View File

@ -251,6 +251,20 @@ if (!$rawfilter) {
<?php
if ($filterent['proto'] == "TCP") {
$filterent['proto'] .= ":{$filterent['tcpflags']}";
} elseif ($filterent['protoid'] == '112') {
$carp_details = array();
if (strlen($filterent['vhid'])) {
$carp_details[] = $filterent['vhid'];
}
if (strlen($filterent['advskew'])) {
$carp_details[] = $filterent['advskew'];
}
if (strlen($filterent['advbase'])) {
$carp_details[] = $filterent['advbase'];
}
if (!empty($carp_details)) {
$filterent['proto'] .= " " . implode("/", $carp_details);
}
}
?>
<td>