mirror of
https://github.com/pi-hole/web.git
synced 2025-12-24 20:55:28 +00:00
Merge pull request #1144 from pi-hole/new/CNAME_inspection_details
Add CNAME blocking states and show more details in CNAME blocking
This commit is contained in:
@@ -45,34 +45,39 @@ $token = $_SESSION['token'];
|
||||
<label>Query status:</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-md-2">
|
||||
<div class="col-md-3">
|
||||
<div class="checkbox">
|
||||
<label><input type="checkbox" id="type_gravity" checked>Blocked (exact)</label>
|
||||
<label><input type="checkbox" id="type_forwarded" checked><strong>Permitted: </strong>forwarded</label>
|
||||
</div>
|
||||
<div class="checkbox">
|
||||
<label><input type="checkbox" id="type_cached" checked><strong>Permitted: </strong>cached</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<div class="col-md-3">
|
||||
<div class="checkbox">
|
||||
<label><input type="checkbox" id="type_forwarded" checked>OK (forwarded)</label>
|
||||
<label><input type="checkbox" id="type_gravity" checked><strong>Blocked: </strong>gravity</label>
|
||||
</div>
|
||||
<div class="checkbox">
|
||||
<label><input type="checkbox" id="type_external" checked><strong>Blocked: </strong>external</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<div class="col-md-3">
|
||||
<div class="checkbox">
|
||||
<label><input type="checkbox" id="type_cached" checked>OK (cached)</label>
|
||||
<label><input type="checkbox" id="type_blacklist" checked><strong>Blocked: </strong>exact blacklist</label>
|
||||
</div>
|
||||
<div class="checkbox">
|
||||
<label><input type="checkbox" id="type_regex" checked><strong>Blocked: </strong>regex blacklist</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<div class="col-md-3">
|
||||
<div class="checkbox">
|
||||
<label><input type="checkbox" id="type_regex" checked>Blocked (regex/wildcard)</label>
|
||||
<label><input type="checkbox" id="type_gravity_CNAME" checked><strong>Blocked: </strong>gravity (CNAME)</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<div class="checkbox">
|
||||
<label><input type="checkbox" id="type_blacklist" checked>Blocked (blacklist)</label>
|
||||
<label><input type="checkbox" id="type_blacklist_CNAME" checked><strong>Blocked: </strong>exact blacklist (CNAME)</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<div class="checkbox">
|
||||
<label><input type="checkbox" id="type_external" checked>Blocked (external)</label>
|
||||
<label><input type="checkbox" id="type_regex_CNAME" checked><strong>Blocked: </strong>regex blacklist (CNAME)</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -195,6 +195,18 @@ function getQueryTypes() {
|
||||
queryType.push([6, 7, 8]);
|
||||
}
|
||||
|
||||
if ($("#type_gravity_CNAME").prop("checked")) {
|
||||
queryType.push(9);
|
||||
}
|
||||
|
||||
if ($("#type_regex_CNAME").prop("checked")) {
|
||||
queryType.push(10);
|
||||
}
|
||||
|
||||
if ($("#type_blacklist_CNAME").prop("checked")) {
|
||||
queryType.push(11);
|
||||
}
|
||||
|
||||
return queryType.join(",");
|
||||
}
|
||||
|
||||
@@ -282,13 +294,13 @@ $(document).ready(function() {
|
||||
break;
|
||||
case 4:
|
||||
color = "red";
|
||||
fieldtext = "Blocked <br class='hidden-lg'>(regex/wildcard)";
|
||||
fieldtext = "Blocked <br class='hidden-lg'>(regex blacklist)";
|
||||
buttontext =
|
||||
'<button type="button" class="btn btn-default btn-sm text-green"><i class="fas fa-check"></i> Whitelist</button>';
|
||||
break;
|
||||
case 5:
|
||||
color = "red";
|
||||
fieldtext = "Blocked <br class='hidden-lg'>(blacklist)";
|
||||
fieldtext = "Blocked <br class='hidden-lg'>(exact blacklist)";
|
||||
buttontext =
|
||||
'<button type="button" class="btn btn-default btn-sm text-green"><i class="fas fa-check"></i> Whitelist</button>';
|
||||
break;
|
||||
@@ -307,6 +319,24 @@ $(document).ready(function() {
|
||||
fieldtext = "Blocked <br class='hidden-lg'>(external, NXRA)";
|
||||
buttontext = "";
|
||||
break;
|
||||
case 9:
|
||||
color = "red";
|
||||
fieldtext = "Blocked (gravity, CNAME)";
|
||||
buttontext =
|
||||
'<button type="button" class="btn btn-default btn-sm text-green"><i class="fas fa-check"></i> Whitelist</button>';
|
||||
break;
|
||||
case 10:
|
||||
color = "red";
|
||||
fieldtext = "Blocked <br class='hidden-lg'>(regex blacklist, CNAME)";
|
||||
buttontext =
|
||||
'<button type="button" class="btn btn-default btn-sm text-green"><i class="fas fa-check"></i> Whitelist</button>';
|
||||
break;
|
||||
case 11:
|
||||
color = "red";
|
||||
fieldtext = "Blocked <br class='hidden-lg'>(exact blacklist, CNAME)";
|
||||
buttontext =
|
||||
'<button type="button" class="btn btn-default btn-sm text-green"><i class="fas fa-check"></i> Whitelist</button>';
|
||||
break;
|
||||
default:
|
||||
color = "black";
|
||||
fieldtext = "Unknown";
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
var table;
|
||||
var groups = [];
|
||||
var token = $("#token").html();
|
||||
var GETDict = {};
|
||||
|
||||
function get_groups() {
|
||||
$.post(
|
||||
@@ -24,6 +25,13 @@ function get_groups() {
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
window.location.search
|
||||
.substr(1)
|
||||
.split("&")
|
||||
.forEach(function(item) {
|
||||
GETDict[item.split("=")[0]] = item.split("=")[1];
|
||||
});
|
||||
|
||||
$("#btnAdd").on("click", addDomain);
|
||||
|
||||
get_groups();
|
||||
@@ -122,6 +130,13 @@ function initTable() {
|
||||
);
|
||||
}
|
||||
|
||||
// Highlight row
|
||||
if ("domainid" in GETDict && data.id === parseInt(GETDict.domainid)) {
|
||||
$(row)
|
||||
.find("td")
|
||||
.addClass("highlight");
|
||||
}
|
||||
|
||||
// Select assigned groups
|
||||
sel.val(data.groups);
|
||||
// Initialize multiselect
|
||||
@@ -166,6 +181,18 @@ function initTable() {
|
||||
data.columns[0].visible = false;
|
||||
// Apply loaded state to table
|
||||
return data;
|
||||
},
|
||||
initComplete: function() {
|
||||
if ("domainid" in GETDict) {
|
||||
var pos = table
|
||||
.column(0, { order: "current" })
|
||||
.data()
|
||||
.indexOf(parseInt(GETDict.domainid));
|
||||
if (pos >= 0) {
|
||||
var page = Math.floor(pos / table.page.info().length);
|
||||
table.page(page).draw(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -166,7 +166,12 @@ $(document).ready(function() {
|
||||
}
|
||||
|
||||
// Query status
|
||||
var blocked, fieldtext, buttontext, colorClass;
|
||||
var blocked,
|
||||
fieldtext,
|
||||
buttontext,
|
||||
colorClass,
|
||||
isCNAME = false;
|
||||
|
||||
switch (data[4]) {
|
||||
case "1":
|
||||
blocked = true;
|
||||
@@ -192,14 +197,26 @@ $(document).ready(function() {
|
||||
case "4":
|
||||
blocked = true;
|
||||
colorClass = "text-red";
|
||||
fieldtext = "Blocked <br class='hidden-lg'>(regex/wildcard)";
|
||||
fieldtext = "Blocked <br class='hidden-lg'>(regex blacklist)";
|
||||
|
||||
if (data.length > 9 && data[9] > -1) {
|
||||
fieldtext =
|
||||
"<a href='groups-domains.php?domainid=" +
|
||||
data[9] +
|
||||
"' class=" +
|
||||
colorClass +
|
||||
">" +
|
||||
fieldtext +
|
||||
' <i class="fas fa-link"></i></a>';
|
||||
}
|
||||
|
||||
buttontext =
|
||||
'<button type="button" class="btn btn-default btn-sm text-green"><i class="fas fa-check"></i> Whitelist</button>';
|
||||
break;
|
||||
case "5":
|
||||
blocked = true;
|
||||
colorClass = "text-red";
|
||||
fieldtext = "Blocked <br class='hidden-lg'>(blacklist)";
|
||||
fieldtext = "Blocked <br class='hidden-lg'>(exact blacklist)";
|
||||
buttontext =
|
||||
'<button type="button" class="btn btn-default btn-sm text-green"><i class="fas fa-check"></i> Whitelist</button>';
|
||||
break;
|
||||
@@ -221,6 +238,30 @@ $(document).ready(function() {
|
||||
fieldtext = "Blocked <br class='hidden-lg'>(external, NXRA)";
|
||||
buttontext = "";
|
||||
break;
|
||||
case "9":
|
||||
blocked = true;
|
||||
colorClass = "text-red";
|
||||
fieldtext = "Blocked (gravity, CNAME)";
|
||||
buttontext =
|
||||
'<button type="button" class="btn btn-default btn-sm text-green"><i class="fas fa-check"></i> Whitelist</button>';
|
||||
isCNAME = true;
|
||||
break;
|
||||
case "10":
|
||||
blocked = true;
|
||||
colorClass = "text-red";
|
||||
fieldtext = "Blocked <br class='hidden-lg'>(regex blacklist, CNAME)";
|
||||
buttontext =
|
||||
'<button type="button" class="btn btn-default btn-sm text-green"><i class="fas fa-check"></i> Whitelist</button>';
|
||||
isCNAME = true;
|
||||
break;
|
||||
case "11":
|
||||
blocked = true;
|
||||
colorClass = "text-red";
|
||||
fieldtext = "Blocked <br class='hidden-lg'>(exact blacklist, CNAME)";
|
||||
buttontext =
|
||||
'<button type="button" class="btn btn-default btn-sm text-green"><i class="fas fa-check"></i> Whitelist</button>';
|
||||
isCNAME = true;
|
||||
break;
|
||||
default:
|
||||
blocked = false;
|
||||
colorClass = "text-black";
|
||||
@@ -228,15 +269,17 @@ $(document).ready(function() {
|
||||
buttontext = "";
|
||||
}
|
||||
|
||||
// Add extra label when blocking happend during deep CNAME inspection
|
||||
if (blocked && data.length > 6 && data[6] === "3") {
|
||||
fieldtext += "<br>CNAME";
|
||||
}
|
||||
|
||||
$(row).addClass(colorClass);
|
||||
$("td:eq(4)", row).html(fieldtext);
|
||||
$("td:eq(6)", row).html(buttontext);
|
||||
|
||||
// Add domain in CNAME chain causing the query to have been blocked
|
||||
var domain = data[2];
|
||||
var CNAME_domain = data[8];
|
||||
if (isCNAME) {
|
||||
$("td:eq(2)", row).text(domain + "\n(blocked " + CNAME_domain + ")");
|
||||
}
|
||||
|
||||
// Check for existence of sixth column and display only if not Pi-holed
|
||||
var replytext;
|
||||
if (data.length > 6 && !blocked) {
|
||||
@@ -387,14 +430,16 @@ $(document).ready(function() {
|
||||
// Domain
|
||||
api.$("td:eq(2)").click(function() {
|
||||
if (autofilter()) {
|
||||
api.search(this.textContent).draw();
|
||||
var domain = this.textContent.split("\n")[0];
|
||||
api.search(domain).draw();
|
||||
$("#resetButton").show();
|
||||
}
|
||||
});
|
||||
api.$("td:eq(2)").hover(
|
||||
function() {
|
||||
if (autofilter()) {
|
||||
this.title = "Click to show only queries with domain " + this.textContent;
|
||||
var domain = this.textContent.split("\n")[0];
|
||||
this.title = "Click to show only queries with domain " + domain;
|
||||
this.style.color = "#72afd2";
|
||||
} else {
|
||||
this.title = "";
|
||||
|
||||
@@ -239,3 +239,7 @@
|
||||
.text-vivid-blue {
|
||||
color: #36f !important;
|
||||
}
|
||||
|
||||
td.highlight {
|
||||
background-color: yellow;
|
||||
}
|
||||
Reference in New Issue
Block a user