Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new blocked by database status and NONE reply type #1869

Merged
merged 1 commit into from
Aug 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion db_queries.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,12 @@
<div class="col-md-3">
<div><input type="checkbox" id="type_forwarded" checked><label for="type_forwarded">Permitted: forwarded</label><br></div>
<div><input type="checkbox" id="type_cached" checked><label for="type_cached">Permitted: cached</label></div>
<div><input type="checkbox" id="type_retried" checked><label for="type_retried">Permitted: Retried</label></div>
<div><input type="checkbox" id="type_retried" checked><label for="type_retried">Permitted: retried</label></div>
</div>
<div class="col-md-3">
<div><input type="checkbox" id="type_gravity" checked><label for="type_gravity">Blocked: gravity</label><br></div>
<div><input type="checkbox" id="type_external" checked><label for="type_external">Blocked: external</label></div>
<div><input type="checkbox" id="type_dbbusy" checked><label for="type_dbbusy">Blocked: database busy</label></div>
</div>
<div class="col-md-3">
<div><input type="checkbox" id="type_blacklist" checked><label for="type_blacklist">Blocked: exact blacklist</label><br></div>
Expand Down
21 changes: 14 additions & 7 deletions scripts/pi-hole/js/db_queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ function getQueryTypes() {
queryType.push([12, 13]);
}

// 14 is defined above

if ($("#type_dbbusy").prop("checked")) {
queryType.push(15);
}

return queryType.join(",");
}

Expand Down Expand Up @@ -172,7 +178,7 @@ function refreshTableData() {
var APIstring = "api_db.php?getAllQueries&from=" + from + "&until=" + until;
// Check if query type filtering is enabled
var queryType = getQueryTypes();
if (queryType !== "1,2,3,4,5,6") {
if (queryType !== "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15") {
APIstring += "&types=" + queryType;
}

Expand All @@ -194,7 +200,9 @@ $(function () {

tableApi = $("#all-queries").DataTable({
rowCallback: function (row, data) {
var fieldtext, buttontext, color;
var fieldtext,
buttontext = "",
color;
switch (data[4]) {
case 1:
color = "red";
Expand Down Expand Up @@ -232,17 +240,14 @@ $(function () {
case 6:
color = "red";
fieldtext = "Blocked <br class='hidden-lg'>(external, IP)";
buttontext = "";
break;
case 7:
color = "red";
fieldtext = "Blocked <br class='hidden-lg'>(external, NULL)";
buttontext = "";
break;
case 8:
color = "red";
fieldtext = "Blocked <br class='hidden-lg'>(external, NXRA)";
buttontext = "";
break;
case 9:
color = "red";
Expand All @@ -265,7 +270,6 @@ $(function () {
case 12:
color = "green";
fieldtext = "Retried";
buttontext = "";
break;
case 13:
color = "green";
Expand All @@ -278,10 +282,13 @@ $(function () {
buttontext =
'<button type="button" class="btn btn-default btn-sm text-red"><i class="fa fa-ban"></i> Blacklist</button>';
break;
case 15:
color = "text-orange";
fieldtext = "Blocked <br class='hidden-lg'>(database is busy)";
break;
default:
color = "black";
fieldtext = "Unknown";
buttontext = "";
}

$(row).css("color", color);
Expand Down
12 changes: 7 additions & 5 deletions scripts/pi-hole/js/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var replyTypes = [
"NOTIMP",
"upstream error",
"DNSSEC",
"NONE",
];
var colTypes = ["time", "query type", "domain", "client", "status", "reply type"];

Expand Down Expand Up @@ -78,7 +79,7 @@ $(function () {
var replyid = parseInt(data[5], 10);
// DNSSEC status
var dnssecStatus;
var ede = data[11];
var ede = data[11] ? data[11] : "";
switch (data[6]) {
case "1":
dnssecStatus = '<br><span class="text-green">SECURE';
Expand Down Expand Up @@ -108,7 +109,7 @@ $(function () {

// Query status
var fieldtext,
buttontext,
buttontext = "",
colorClass = false,
isCNAME = false,
regexLink = false;
Expand Down Expand Up @@ -197,23 +198,24 @@ $(function () {
case "12":
colorClass = "text-green";
fieldtext = "Retried";
buttontext = "";
break;
case "13":
colorClass = "text-green";
fieldtext = "Retried <br class='hidden-lg'>(ignored)";
buttontext = "";
break;
case "14":
colorClass = "text-green";
fieldtext = "OK <br class='hidden-lg'>(already forwarded)" + dnssecStatus;
buttontext =
'<button type="button" class="btn btn-default btn-sm text-red"><i class="fa fa-ban"></i> Blacklist</button>';
break;
case "15":
colorClass = "text-orange";
fieldtext = "Blocked <br class='hidden-lg'>(database is busy)";
break;
default:
colorClass = false;
fieldtext = "Unknown (" + parseInt(data[4], 10) + ")";
buttontext = "";
}

// Add EDE here if available and not included in dnssecStatus
Expand Down