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 stale cache query status #2421

Merged
merged 3 commits into from
Nov 14, 2022
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
2 changes: 1 addition & 1 deletion api_db.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions db_queries.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<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_cached_stale" checked><label for="type_cached_stale">Permitted: stale cache</label></div>
<div><input type="checkbox" id="type_retried" checked><label for="type_retried">Permitted: retried</label></div>
</div>
<div class="col-md-3">
Expand Down
13 changes: 12 additions & 1 deletion scripts/pi-hole/js/db_queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ function excludeStatusTypes() {
statusType.push(16);
}

if ($("#type_cached_stale").prop("checked") === false) {
statusType.push(17);
}

return statusType.join(",");
}

Expand All @@ -176,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
Expand Down Expand Up @@ -349,6 +353,13 @@ $(function () {
"<span class='text-orange'>Blocked <br class='hidden-lg'>(special domain)</span>";
blocked = true;
break;
case 17:
fieldtext =
"<span class='text-orange'>OK</span> <br class='hidden-lg'>(stale cache)" +
dnssecStatus;
buttontext =
'<button type="button" class="btn btn-default btn-sm text-red"><i class="fa fa-ban"></i> Blacklist</button>';
break;
default:
fieldtext = "Unknown (" + parseInt(data[4], 10) + ")";
}
Expand Down
9 changes: 8 additions & 1 deletion scripts/pi-hole/js/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,13 @@ $(function () {
"<span class='text-orange'>Blocked <br class='hidden-lg'>(special domain)</span>";
blocked = true;
break;
case "17":
fieldtext =
"<span class='text-orange'>OK</span> <br class='hidden-lg'>(stale cache)" +
dnssecStatus;
buttontext =
'<button type="button" class="btn btn-default btn-sm text-red"><i class="fa fa-ban"></i> Blacklist</button>';
break;
default:
fieldtext = "Unknown (" + parseInt(data[4], 10) + ")";
}
Expand Down Expand Up @@ -464,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");
Expand Down