From 39a4532374e8b2e568d54ac7750d1bc226b2026f Mon Sep 17 00:00:00 2001 From: DL6ER Date: Thu, 16 Apr 2020 20:14:34 +0000 Subject: [PATCH 1/4] Add specific titles in Query Log when opened with special links for upstream server or query type filtering. Signed-off-by: DL6ER --- queries.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/queries.php b/queries.php index cd5978bd..16ad97a4 100644 --- a/queries.php +++ b/queries.php @@ -44,6 +44,19 @@ else if(isset($_GET["client"])) { $showing .= " queries for client ".htmlentities($_GET["client"]); } +else if(isset($_GET["forwarddest"])) +{ + $showing .= " queries for upstream destination ".htmlentities($_GET["forwarddest"]); +} +else if(isset($_GET["querytype"])) +{ + $qtypes = ["A (IPv4)", "AAAA (IPv6)", "ANY", "SRV", "SOA", "PTR", "TXT", "NAPTR"]; + $qtype = intval($_GET["querytype"]); + if($qtype > 0 && $qtype <= count($qtypes)) + $showing .= " ".$qtypes[$qtype-1]." queries"; + else + $showing .= " type ".$qtype." queries"; +} else if(isset($_GET["domain"])) { $showing .= " queries for domain ".htmlentities($_GET["domain"]); From 64a2419fa9ad92b3734f10ad969aa76cefdcbb30 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Thu, 16 Apr 2020 20:30:14 +0000 Subject: [PATCH 2/4] Add ability to filter for blocked queries in conjunction the client filter in the Query Log. Request such filtered data when clicking on a client in the Top Clients (blocked only) table on the dashboard. Signed-off-by: DL6ER --- api_FTL.php | 5 +++++ queries.php | 4 ++++ scripts/pi-hole/js/index.js | 2 +- scripts/pi-hole/js/queries.js | 4 ++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/api_FTL.php b/api_FTL.php index 85ee3f8a..daf72307 100644 --- a/api_FTL.php +++ b/api_FTL.php @@ -288,6 +288,11 @@ else // Get specific domain only sendRequestFTL("getallqueries-domain ".$_GET['domain']); } + else if(isset($_GET['client']) && (isset($_GET['type']) && $_GET['type'] === "blocked")) + { + // Get specific client only + sendRequestFTL("getallqueries-client-blocked ".$_GET['client']); + } else if(isset($_GET['client'])) { // Get specific client only diff --git a/queries.php b/queries.php index 16ad97a4..2342fd76 100644 --- a/queries.php +++ b/queries.php @@ -28,6 +28,10 @@ if(isset($setupVars["API_QUERY_LOG_SHOW"])) $showing = "showing no queries (due to setting)"; } } +else if(isset($_GET["type"]) && $_GET["type"] === "blocked") +{ + $showing = "showing blocked"; +} else { // If filter variable is not set, we diff --git a/scripts/pi-hole/js/index.js b/scripts/pi-hole/js/index.js index 7f587f2e..4492f1da 100644 --- a/scripts/pi-hole/js/index.js +++ b/scripts/pi-hole/js/index.js @@ -587,7 +587,7 @@ function updateTopClientsChart() { url = '' + clientname + diff --git a/scripts/pi-hole/js/queries.js b/scripts/pi-hole/js/queries.js index d7008d93..e58da7a3 100644 --- a/scripts/pi-hole/js/queries.js +++ b/scripts/pi-hole/js/queries.js @@ -148,6 +148,10 @@ $(function () { APIstring += "=100"; } + if ("type" in GETDict) { + APIstring += "&type=" + GETDict.type; + } + tableApi = $("#all-queries").DataTable({ rowCallback: function (row, data) { // DNSSEC status From d914e09941038a89d8eb03bf3393d99cb8465050 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Thu, 16 Apr 2020 20:38:42 +0000 Subject: [PATCH 3/4] Be a bit more specific about the upstream destination if it is the blocklist or the cache. Signed-off-by: DL6ER --- queries.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/queries.php b/queries.php index 2342fd76..e3f9ea6d 100644 --- a/queries.php +++ b/queries.php @@ -50,7 +50,12 @@ else if(isset($_GET["client"])) } else if(isset($_GET["forwarddest"])) { - $showing .= " queries for upstream destination ".htmlentities($_GET["forwarddest"]); + if($_GET["forwarddest"] === "blocklist") + $showing .= " queries answered from blocklists"; + elseif($_GET["forwarddest"] === "cache") + $showing .= " queries answered from cache"; + else + $showing .= " queries for upstream destination ".htmlentities($_GET["forwarddest"]); } else if(isset($_GET["querytype"])) { From 01aca3242f07f050c43f217d9b7e7fb9cbb2966d Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 2 Aug 2020 20:05:49 +0200 Subject: [PATCH 4/4] Add link to Query Log from Clients over Time bar graph bars. Signed-off-by: DL6ER --- scripts/pi-hole/js/index.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/scripts/pi-hole/js/index.js b/scripts/pi-hole/js/index.js index 4492f1da..459e9521 100644 --- a/scripts/pi-hole/js/index.js +++ b/scripts/pi-hole/js/index.js @@ -996,6 +996,24 @@ $(function () { return false; }); + $("#clientsChart").click(function (evt) { + var activePoints = clientsChart.getElementAtEvent(evt); + if (activePoints.length > 0) { + //get the internal index of slice in pie chart + var clickedElementindex = activePoints[0]._index; + + //get specific label by index + var label = clientsChart.data.labels[clickedElementindex]; + + //get value by index + var from = label / 1000 - 300; + var until = label / 1000 + 300; + window.location.href = "queries.php?from=" + from + "&until=" + until; + } + + return false; + }); + if (document.getElementById("queryTypePieChart")) { ctx = document.getElementById("queryTypePieChart").getContext("2d"); queryTypePieChart = new Chart(ctx, {