From 92c7c224291255852c8913c8258475d9fb0cb0bc Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 7 Nov 2022 14:04:14 +0100 Subject: [PATCH 1/3] Add stale cache query status Signed-off-by: DL6ER --- db_queries.php | 1 + scripts/pi-hole/js/db_queries.js | 11 +++++++++++ scripts/pi-hole/js/queries.js | 7 +++++++ 3 files changed, 19 insertions(+) diff --git a/db_queries.php b/db_queries.php index d08edf297..1cbe9a633 100644 --- a/db_queries.php +++ b/db_queries.php @@ -49,6 +49,7 @@

+
diff --git a/scripts/pi-hole/js/db_queries.js b/scripts/pi-hole/js/db_queries.js index 46f418587..3a5aac236 100644 --- a/scripts/pi-hole/js/db_queries.js +++ b/scripts/pi-hole/js/db_queries.js @@ -167,6 +167,10 @@ function excludeStatusTypes() { statusType.push(16); } + if ($("#type_cached_stale").prop("checked") === false) { + statusType.push(17); + } + return statusType.join(","); } @@ -349,6 +353,13 @@ $(function () { "Blocked (special domain)"; blocked = true; break; + case 17: + fieldtext = + "OK (stale cache)" + + dnssecStatus; + buttontext = + ''; + break; default: fieldtext = "Unknown (" + parseInt(data[4], 10) + ")"; } diff --git a/scripts/pi-hole/js/queries.js b/scripts/pi-hole/js/queries.js index 79ff213d3..1bccf9eaf 100644 --- a/scripts/pi-hole/js/queries.js +++ b/scripts/pi-hole/js/queries.js @@ -219,6 +219,13 @@ $(function () { "Blocked (special domain)"; blocked = true; break; + case "17": + fieldtext = + "OK (stale cache)" + + dnssecStatus; + buttontext = + ''; + break; default: fieldtext = "Unknown (" + parseInt(data[4], 10) + ")"; } From 1afaa95b519f06099f446874f61229f37858e6f9 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Wed, 9 Nov 2022 20:56:54 +0100 Subject: [PATCH 2/3] Update db_queries.php Co-authored-by: RD WebDesign Signed-off-by: DL6ER --- db_queries.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db_queries.php b/db_queries.php index 1cbe9a633..af5b0af18 100644 --- a/db_queries.php +++ b/db_queries.php @@ -49,7 +49,7 @@

-
+
From ec1e54344f2607a1255752b8f6983cca080ed14e Mon Sep 17 00:00:00 2001 From: DL6ER Date: Thu, 10 Nov 2022 19:26:20 +0100 Subject: [PATCH 3/3] Addressing review comments. Signed-off-by: DL6ER --- api_db.php | 2 +- scripts/pi-hole/js/db_queries.js | 2 +- scripts/pi-hole/js/queries.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/api_db.php b/api_db.php index fca897a2e..f060d47bb 100644 --- a/api_db.php +++ b/api_db.php @@ -192,7 +192,7 @@ $limit = ' AND timestamp <= :until'; } // Select top permitted domains only - $stmt = $db->prepare('SELECT domain,count(domain) FROM queries WHERE status IN (2,3,12,13,14)'.$limit.' GROUP by domain order by count(domain) desc limit 20'); + $stmt = $db->prepare('SELECT domain,count(domain) FROM queries WHERE status IN (2,3,12,13,14,17)'.$limit.' GROUP by domain order by count(domain) desc limit 20'); $stmt->bindValue(':from', intval($_GET['from']), SQLITE3_INTEGER); $stmt->bindValue(':until', intval($_GET['until']), SQLITE3_INTEGER); $results = $stmt->execute(); diff --git a/scripts/pi-hole/js/db_queries.js b/scripts/pi-hole/js/db_queries.js index 3a5aac236..efa85074f 100644 --- a/scripts/pi-hole/js/db_queries.js +++ b/scripts/pi-hole/js/db_queries.js @@ -180,7 +180,7 @@ var reloadCallback = function () { var data = tableApi.rows().data(); for (var i = 0; i < data.length; i++) { statistics[0]++; // TOTAL query - if (data[i][4] === 1 || (data[i][4] > 4 && ![10, 12, 13, 14].includes(data[i][4]))) { + if (data[i][4] === 1 || (data[i][4] > 4 && ![10, 12, 13, 14, 17].includes(data[i][4]))) { statistics[2]++; // EXACT blocked } else if (data[i][4] === 3) { statistics[1]++; // CACHE query diff --git a/scripts/pi-hole/js/queries.js b/scripts/pi-hole/js/queries.js index 1bccf9eaf..163d282b8 100644 --- a/scripts/pi-hole/js/queries.js +++ b/scripts/pi-hole/js/queries.js @@ -471,7 +471,7 @@ $(function () { $("#all-queries tbody").on("click", "button", function () { var data = tableApi.row($(this).parents("tr")).data(); - if (data[4] === "2" || data[4] === "3" || data[4] === "14") { + if (data[4] === "2" || data[4] === "3" || data[4] === "14" || data[4] === "17") { utils.addFromQueryLog(data[2], "black"); } else { utils.addFromQueryLog(data[2], "white");