diff --git a/api_db.php b/api_db.php
index a10212a7..3649b768 100644
--- a/api_db.php
+++ b/api_db.php
@@ -64,7 +64,7 @@ if (isset($_GET['getAllQueries']) && $auth)
{
$from = intval($_GET["from"]);
$until = intval($_GET["until"]);
- $dbquery = "SELECT timestamp, type, domain, client, status, forward FROM queries WHERE timestamp >= :from AND timestamp <= :until ";
+ $dbquery = "SELECT timestamp, type, domain, client, status, forward, reply_type, reply_time, dnssec FROM queries WHERE timestamp >= :from AND timestamp <= :until ";
if(isset($_GET["types"]))
{
$types = $_GET["types"];
@@ -101,14 +101,19 @@ if (isset($_GET['getAllQueries']) && $auth)
$first = false;
}
- // Convert query type ID to name, encode domain, encode destination
- $query_type = getQueryTypeStr($row[1]);
+ // Format, encode, transform each field (if necessary).
+ $time = $row[0];
+ $query_type = getQueryTypeStr($row[1]); // Convert query type ID to name
$domain = utf8_encode(str_replace("~"," ",$row[2]));
+ $client = $row[3];
+ $status = $row[4];
$destination = utf8_encode($row[5]);
+ $reply_type = $row[6];
+ $reply_time = $row[7];
+ $dnssec = $row[8];
// Insert into array and output it in JSON format
- // array: time type domain client status upstream destination
- echo json_encode([$row[0], $query_type, $domain, $row[3], $row[4], $destination]);
+ echo json_encode([$time, $query_type, $domain, $client, $status, $destination, $reply_type, $reply_time, $dnssec]);
}
}
diff --git a/db_queries.php b/db_queries.php
index e283b01c..8d6ccaa9 100644
--- a/db_queries.php
+++ b/db_queries.php
@@ -180,6 +180,7 @@
Domain |
Client |
Status |
+ Reply |
Action |
@@ -190,6 +191,7 @@
Domain |
Client |
Status |
+ Reply |
Action |
diff --git a/scripts/pi-hole/js/db_queries.js b/scripts/pi-hole/js/db_queries.js
index f502dff4..eb9478a4 100644
--- a/scripts/pi-hole/js/db_queries.js
+++ b/scripts/pi-hole/js/db_queries.js
@@ -20,6 +20,23 @@ var datepickerManuallySelected = false;
var dateformat = "MMMM Do YYYY, HH:mm";
+var replyTypes = [
+ "N/A",
+ "NODATA",
+ "NXDOMAIN",
+ "CNAME",
+ "IP",
+ "DOMAIN",
+ "RRNAME",
+ "SERVFAIL",
+ "REFUSED",
+ "NOTIMP",
+ "upstream error",
+ "DNSSEC",
+ "NONE",
+ "BLOB",
+];
+
// Do we want to filter queries?
var GETDict = {};
window.location.search
@@ -210,6 +227,34 @@ $(function () {
tableApi = $("#all-queries").DataTable({
rowCallback: function (row, data) {
+ var replyid = parseInt(data[6], 10);
+ var dnssecStatus;
+ switch (data[8]) {
+ case "1":
+ dnssecStatus = '
SECURE';
+ break;
+ case "2":
+ dnssecStatus = '
INSECURE';
+ break;
+ case "3":
+ dnssecStatus = '
BOGUS';
+ break;
+ case "4":
+ dnssecStatus = '
ABANDONED';
+ break;
+ case "5":
+ dnssecStatus = '
UNKNOWN';
+ break;
+ default:
+ // No DNSSEC
+ dnssecStatus = "";
+ }
+
+ if (dnssecStatus.length > 0) {
+ if (replyid === 7) dnssecStatus += " (refused upstream)";
+ dnssecStatus += "";
+ }
+
var fieldtext,
buttontext = "",
blocked = false;
@@ -222,14 +267,18 @@ $(function () {
break;
case 2:
fieldtext =
- "OK (forwarded to
" +
+ replyid === 0
+ ? "OK (sent to
"
+ : "OK (answered by
";
+ fieldtext +=
(data.length > 5 && data[5] !== "N/A" ? data[5] : "") +
+ dnssecStatus +
")";
buttontext =
'';
break;
case 3:
- fieldtext = "OK
(cache)";
+ fieldtext = "OK
(cache)" + dnssecStatus;
buttontext =
'';
break;
@@ -305,13 +354,28 @@ $(function () {
fieldtext = "Unknown (" + parseInt(data[4], 10) + ")";
}
+ // Cannot block internal queries of this type
+ if ((data[1] === "DNSKEY" || data[1] === "DS") && data[3] === "pi.hole") buttontext = "";
+
$(row).addClass(blocked === true ? "blocked-row" : "allowed-row");
if (localStorage && localStorage.getItem("colorfulQueryLog_chkbox") === "true") {
$(row).addClass(blocked === true ? "text-red" : "text-green");
}
+ // Check for existence of sixth column and display only if not Pi-holed
+ var replytext =
+ replyid >= 0 && replyid < replyTypes.length ? replyTypes[replyid] : "? (" + replyid + ")";
+
+ replytext += '';
+
$("td:eq(4)", row).html(fieldtext);
- $("td:eq(5)", row).html(buttontext);
+ $("td:eq(5)", row).html(replytext);
+ $("td:eq(6)", row).html(buttontext);
+
+ // Show response time only when reply is not N/A
+ if (data.length > 7 && replyid !== 0) {
+ $("td:eq(5)", row).append(" (" + (0.1 * data[7]).toFixed(1) + "ms)");
+ }
// Substitute domain by "." if empty
var domain = data[2];
@@ -343,7 +407,7 @@ $(function () {
order: [[0, "desc"]],
columns: [
{
- width: "15%",
+ width: "12%",
render: function (data, type) {
if (type === "display") {
return moment
@@ -354,11 +418,12 @@ $(function () {
return data;
},
},
- { width: "10%" },
- { width: "40%" },
- { width: "20%", type: "ip-address" },
- { width: "10%" },
- { width: "5%" },
+ { width: "9%" },
+ { width: "36%" },
+ { width: "10%", type: "ip-address" },
+ { width: "15%" },
+ { width: "9%" },
+ { width: "9%" },
],
lengthMenu: [
[10, 25, 50, 100, -1],