From c120bd8da9cd31857572784202e1dca465970688 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Sun, 21 Dec 2014 17:48:35 +0545 Subject: Handle firewall log widget display formats the same way for the initial display and for updated rows done by Java Script. Now we receive the source IP and port, destination IP and port, all in separate fields so they can be put together in whatever combination for display. IPv6 displayed addresses are shown inside "[ ]" so that any following port has the standard syntax like "[a:b::c:d]:123" - this makes it obvious that the last numbers are a port number, and not part of the IPv6 address. The "title" has IP+Port - that is displayed when hovering over the box in general. The href to diag_dns.php has hover text "Reverse Resolve with DNS" and the "?host=" sends just the IP address (without IPv6 square brackets). The text displayed in the link is the IP address (with square brackets if an IPv6 address). For the destination column, if there is a destinaion port, it is displayed in ordinary text ":port" after the IP address. The blank not-displayed row at the end of the table is removed - this fixes the problem with counting the rows of the table where rows would disappear at each update. --- usr/local/www/widgets/widgets/log.widget.php | 56 +++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 10 deletions(-) (limited to 'usr/local/www') diff --git a/usr/local/www/widgets/widgets/log.widget.php b/usr/local/www/widgets/widgets/log.widget.php index fb240fb..2677ee5 100644 --- a/usr/local/www/widgets/widgets/log.widget.php +++ b/usr/local/www/widgets/widgets/log.widget.php @@ -105,11 +105,30 @@ else /* Called by the AJAX updater */ function format_log_line(row) { - var line = '' + row[0] + '<\/td>' + - '' + row[1].slice(0,-3) + '<\/td>' + - '' + row[2] + '<\/td>' + - '' + row[3] + '<\/td>' + - '' + row[4] + '<\/td>'; + var rrText = ""; + + if ( row[8] == '6' ) { + srcIP = '[' + row[3] + ']'; + dstIP = '[' + row[5] + ']'; + } else { + srcIP = row[3]; + dstIP = row[5]; + } + + if ( row[4] == '' ) + srcPort = ''; + else + srcPort = ':' + row[4]; + if ( row[6] == '' ) + dstPort = ''; + else + dstPort = ':' + row[6]; + + var line = '' + row[0] + '' + + '' + row[1].slice(0,-3) + '' + + '' + row[2] + '' + + '' + srcIP + '' + + '' + dstIP + '' + dstPort + ''; var nentriesacts = ""; var nentriesinterfaces = ""; @@ -188,6 +207,24 @@ function format_log_line(row) { foreach ($filterlog as $filterent): $evenRowClass = $rowIndex % 2 ? " listMReven" : " listMRodd"; $rowIndex++; + if ($filterent['version'] == '6') { + $srcIP = "[" . htmlspecialchars($filterent['srcip']) . "]"; + $dstIP = "[" . htmlspecialchars($filterent['dstip']) . "]"; + } else { + $srcIP = htmlspecialchars($filterent['srcip']); + $dstIP = htmlspecialchars($filterent['dstip']); + } + + if ($filterent['srcport']) + $srcPort = ":" . htmlspecialchars($filterent['srcport']); + else + $srcPort = ""; + + if ($filterent['dstport']) + $dstPort = ":" . htmlspecialchars($filterent['dstport']); + else + $dstPort = ""; + ?> @@ -197,19 +234,18 @@ function format_log_line(row) { - + " title=""> - - + + " title=""> - + - -- cgit v1.1