Commit b4395817 authored by Ad Schellevis's avatar Ad Schellevis

(legacy) filter_log.inv move convert_real_interface_to_friendly_descr out of...

(legacy) filter_log.inv move convert_real_interface_to_friendly_descr out of parse loop, https://github.com/opnsense/core/issues/672
parent 36710dce
...@@ -32,6 +32,22 @@ global $buffer_rules_rdr, $buffer_rules_normal; ...@@ -32,6 +32,22 @@ global $buffer_rules_rdr, $buffer_rules_normal;
$buffer_rules_rdr = array(); $buffer_rules_rdr = array();
$buffer_rules_normal = array(); $buffer_rules_normal = array();
function conv_log_interface_names()
{
global $config;
// collect interface names
$interface_names = array();
$interface_names['enc0'] = gettext("IPsec");
if (!empty($config['interfaces'])) {
foreach ($config['interfaces'] as $intfkey => $interface) {
$interface_names[$interface['if']] = !empty($interface['descr']) ? $interface['descr'] : $intfkey;
}
}
return $interface_names;
}
/* format filter logs */ /* format filter logs */
function conv_log_filter($logfile, $nentries, $tail = 50, $filtertext = '', $filterinterface = null) function conv_log_filter($logfile, $nentries, $tail = 50, $filtertext = '', $filterinterface = null)
{ {
...@@ -53,13 +69,13 @@ function conv_log_filter($logfile, $nentries, $tail = 50, $filtertext = '', $fil ...@@ -53,13 +69,13 @@ function conv_log_filter($logfile, $nentries, $tail = 50, $filtertext = '', $fil
$filterlog = array(); $filterlog = array();
$counter = 0; $counter = 0;
$interface_names = conv_log_interface_names();
foreach ($logarr as $logent) { foreach ($logarr as $logent) {
if ($counter >= $nentries) { if ($counter >= $nentries) {
break; break;
} }
$flent = parse_filter_line($logent); $flent = parse_filter_line($logent, $interface_names);
if (isset($flent) && is_array($flent)) { if (isset($flent) && is_array($flent)) {
if ($filterinterface == null || strtoupper($filterinterface) == $flent['interface']) { if ($filterinterface == null || strtoupper($filterinterface) == $flent['interface']) {
if ( (!is_array($filtertext) && match_filter_line ($flent, $filtertext)) || if ( (!is_array($filtertext) && match_filter_line ($flent, $filtertext)) ||
...@@ -130,7 +146,7 @@ function in_arrayi($needle, $haystack) ...@@ -130,7 +146,7 @@ function in_arrayi($needle, $haystack)
return in_array(strtolower($needle), array_map('strtolower', $haystack)); return in_array(strtolower($needle), array_map('strtolower', $haystack));
} }
function parse_filter_line($line) function parse_filter_line($line, $interface_names = array())
{ {
$flent = array(); $flent = array();
$log_split = ''; $log_split = '';
...@@ -154,7 +170,7 @@ function parse_filter_line($line) ...@@ -154,7 +170,7 @@ function parse_filter_line($line)
$flent['anchor'] = $rule_data[$field++]; $flent['anchor'] = $rule_data[$field++];
$field++; // skip field $field++; // skip field
$flent['realint'] = $rule_data[$field++]; $flent['realint'] = $rule_data[$field++];
$flent['interface'] = convert_real_interface_to_friendly_descr($flent['realint']); $flent['interface'] = !empty($interface_names[$flent['realint']]) ? $interface_names[$flent['realint']] : $flent['realint'] ;
$flent['reason'] = $rule_data[$field++]; $flent['reason'] = $rule_data[$field++];
$flent['act'] = $rule_data[$field++]; $flent['act'] = $rule_data[$field++];
$flent['direction'] = $rule_data[$field++]; $flent['direction'] = $rule_data[$field++];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment