From f15c1f3d4c9b8b5dd4573fa86fa294fb3b5488da Mon Sep 17 00:00:00 2001 From: stilez Date: Wed, 19 Feb 2014 02:53:07 +0000 Subject: AJAX-ify DNS lookups in standard firewall/filter The standard firewall log has lookup ability but these open in a new tab/window, they don't show in the log, other places the same IP appears in the log aren't visibly resolved, - basically its begging for AJAX-ing. This commit is simple, elegant, simplifies the interface, and does the following: 1) Handles AJAX efficiently, and should be pretty robust against untrustworthy data/bad return data 2) Retains a single "Click to resolve" icon (and its "hover" tip) next to each IP 3) On clicking: - *all* visible log occurrences of that IP, whether as source or dest, are suffixed in small with the resolved name (or "Cannot resolve") in font - the icons next to all occurrences of that IP are replaced by equivalent "faded" icons, and the onclick action removed, for visual guidance 4) The replacement uses standard jQuery, so even on a log of several thousand, the click response is almost immediate. 5) The log looks pretty elegant done this way - it doesn't "fill up with junk" in order to show the resolved lookup, and it's simpler and easier than the current version. No obvious drawbacks. (I haven't done this for the dynamic or summary logs - I think the dynamic one could scroll too quickly for individual "item by item" to be useful) --- usr/local/www/diag_logs_filter.php | 69 ++++++++++++++++++++++++++++++++------ 1 file changed, 59 insertions(+), 10 deletions(-) (limited to 'usr/local') diff --git a/usr/local/www/diag_logs_filter.php b/usr/local/www/diag_logs_filter.php index e4cf996..09a683f 100755 --- a/usr/local/www/diag_logs_filter.php +++ b/usr/local/www/diag_logs_filter.php @@ -46,6 +46,20 @@ require("guiconfig.inc"); require_once("filter_log.inc"); +# --- AJAX RESOLVE --- +if (isset($_POST['resolve'])) { + $ip = strtolower($_POST['resolve']); + $res = (is_ipaddr($ip) ? gethostbyaddr($ip) : ''); + + if ($res && $res != $ip) + $response = array('resolve_ip' => $ip, 'resolve_text' => $res); + else + $response = array('resolve_ip' => $ip, 'resolve_text' => gettext("Cannot resolve")); + + echo json_encode(str_replace("\\","\\\\", $response)); // single escape chars can break JSON decode + exit; +} + function getGETPOSTsettingvalue($settingname, $default) { $settingvalue = $default; @@ -351,25 +365,21 @@ include("head.inc"); } $srcstr = $filterent['srcip'] . get_port_with_service($filterent['srcport'], $proto); + $src_htmlclass = str_replace('.', '-', $filterent['srcip']); $dststr = $filterent['dstip'] . get_port_with_service($filterent['dstport'], $proto); + $dst_htmlclass = str_replace('.', '-', $filterent['dstip']); ?> - &dialog_output=true', outputrule);" title=""> - Icon Reverse Resolve with DNS - "> - Icon Reverse Resolve with DNS + ');" title="" class="ICON-" border="0" src="/themes//images/icons/icon_log.gif" alt="Icon Reverse Resolve with DNS"/> " title="" onclick="return confirm('')"> Icon Easy Rule: Add to Block List - + ';?> - &dialog_output=true', outputrule);" title=""> - Icon Reverse Resolve with DNS - "> - Icon Reverse Resolve with DNS + ');" title="" class="ICON-" border="0" src="/themes//images/icons/icon_log.gif" alt="Icon Reverse Resolve with DNS"/> " title="" onclick="return confirm('')"> Icon Easy Rule: Pass this traffic - + ';?> TCP Flags: F - FIN, S - SYN, A or . - ACK, R - RST, P - PSH, U - URG, E - ECE, W - CWR

+ + + + -- cgit v1.1