From af2c372454cae89f2311269f5858e66ebe6d3417 Mon Sep 17 00:00:00 2001 From: BBcan177 Date: Fri, 13 Feb 2015 01:01:14 -0500 Subject: pfBlockerNG - Alerts Tab Modifications 1) Move Hostname lookup to top of script to improve lookup speed. 2) Remove un-necessary Include 3) Use clog instead of grep command 4) If List Column is greater then 17 Characters, Truncate it. 5) Add Timeout to Auto-Hostname Lookup. --- config/pfblockerng/pfblockerng_alerts.php | 46 +++++++++++++++++-------------- 1 file changed, 26 insertions(+), 20 deletions(-) (limited to 'config/pfblockerng/pfblockerng_alerts.php') diff --git a/config/pfblockerng/pfblockerng_alerts.php b/config/pfblockerng/pfblockerng_alerts.php index 7b84bca8..f03f7040 100644 --- a/config/pfblockerng/pfblockerng_alerts.php +++ b/config/pfblockerng/pfblockerng_alerts.php @@ -39,9 +39,19 @@ POSSIBILITY OF SUCH DAMAGE. */ +// Auto-Resolve Hostnames +if (isset($_REQUEST['getpfhostname'])) { + $getpfhostname = htmlspecialchars($_REQUEST['getpfhostname']); + $hostname = htmlspecialchars(gethostbyaddr($getpfhostname), ENT_QUOTES); + if ($hostname == $getpfhostname) { + $hostname = 'unknown'; + } + echo $hostname; + die; +} + require_once("util.inc"); require_once("guiconfig.inc"); -require_once("globals.inc"); require_once("filter_log.inc"); require_once("/usr/local/pkg/pfblockerng/pfblockerng.inc"); @@ -267,18 +277,6 @@ if (isset($_POST['addsuppress'])) { } } -// Auto-Resolve Hostnames -if (isset($_REQUEST['getpfhostname'])) { - $getpfhostname = htmlspecialchars($_REQUEST['getpfhostname']); - $hostname = htmlspecialchars(gethostbyaddr($getpfhostname), ENT_QUOTES); - if ($hostname == $getpfhostname) { - $hostname = 'unknown'; - } - echo $hostname; - die; -} - - // Host Resolve Function lookup function getpfbhostname($type = 'src', $hostip, $countme = 0) { $hostnames['src'] = ''; @@ -448,9 +446,9 @@ if ($pfb['runonce']) { // pfSense versions below 2.2 have the Logfiles in two lines. if ($pfb['pfsenseversion'] >= '2.2') { - $pfblines = exec("/usr/bin/grep -c ^ {$filter_logfile}"); + $pfblines = exec("/usr/local/sbin/clog {$filter_logfile} | /usr/bin/grep -c ^"); } else { - $pfblines = (exec("/usr/bin/grep -c ^ {$filter_logfile}") /2 ); + $pfblines = (exec("/usr/local/sbin/clog {$filter_logfile} | /usr/bin/grep -c ^") /2 ); } $fields_array = conv_log_filter($filter_logfile, $pfblines, $pfblines); @@ -683,6 +681,14 @@ if (!empty($fields_array)) { } } + $pfb_matchtitle = "Country Block Rules cannot be suppressed.\n\nTo allow a particular Country IP, either remove the particular Country or add the Host\nto a Permit Alias in the Firewall Tab.\n\nIf the IP is not listed beside the List, this means that the Block is a /32 entry.\nOnly /32 or /24 CIDR Hosts can be suppressed.\n\nIf (Duplication) Checking is not enabled. You may see /24 and /32 CIDR Blocks for a given blocked Host"; + + // Truncate Long List Names + if (strlen($pfb_match[1]) >= 17) { + $pfb_matchtitle = $pfb_match[1]; + $pfb_match[1] = substr($pfb_match[1], 0, 16) . '...'; + } + // Print Alternating Line Shading if ($pfb['pfsenseversion'] > '2.0') { $alertRowEvenClass = "listMReven"; @@ -706,7 +712,7 @@ if (!empty($fields_array)) { {$src_icons}{$fields['srcip']}{$srcport}
{$hostname['src']} {$dst_icons}{$fields['dstip']}{$dstport}
{$hostname['dst']} {$countrycode} - {$pfb_match[1]}
{$pfb_match[2]}"; + {$pfb_match[1]}
{$pfb_match[2]}"; $counter++; if ($counter > 0 && $rtype == "block") { $mycounter = $counter; @@ -756,10 +762,10 @@ function findhostnames(counter) { ) } - var lines = ; - for (i = 0; i < lines; i++) { - findhostnames(i); - } +var lines = ; +for (alertcount = 0; alertcount < lines; alertcount++) { + setTimeout(findhostnames(alertcount), 30); +} //]]> -- cgit v1.2.3