Skip to content

Commit

Permalink
Simply reply type code.
Browse files Browse the repository at this point in the history
Signed-off-by: DL6ER <[email protected]>
  • Loading branch information
DL6ER committed Apr 26, 2020
1 parent 4d9409e commit efe0244
Showing 1 changed file with 22 additions and 53 deletions.
75 changes: 22 additions & 53 deletions scripts/pi-hole/js/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,21 @@ var tableApi;
var colHighlightColor = "#ffefad";
var tableFilters = [];

var replyTypes = [
"N/A",
"NODATA",
"NXDOMAIN",
"CNAME",
"IP",
"DOMAIN",
"RRNAME",
"SERVFAIL",
"REFUSED",
"NOTIMP",
"upstream error",
];
var colTypes = ["time", "query type", "domain", "client", "status", "reply type"];

function add(domain, list) {
var token = $("#token").text();
var alertModal = $("#alertModal");
Expand Down Expand Up @@ -164,37 +179,32 @@ $(document).ready(function() {
}

// Query status
var blocked,
fieldtext,
var fieldtext,
buttontext,
colorClass,
isCNAME = false,
regexLink = false;

switch (data[4]) {
case "1":
blocked = true;
colorClass = "text-red";
fieldtext = "Blocked (gravity)";
buttontext =
'<button type="button" class="btn btn-default btn-sm text-green"><i class="fas fa-check"></i> Whitelist</button>';
break;
case "2":
blocked = false;
colorClass = "text-green";
fieldtext = "OK <br class='hidden-lg'>(forwarded)" + dnssec_status;
buttontext =
'<button type="button" class="btn btn-default btn-sm text-red"><i class="fa fa-ban"></i> Blacklist</button>';
break;
case "3":
blocked = false;
colorClass = "text-green";
fieldtext = "OK <br class='hidden-lg'>(cached)" + dnssec_status;
buttontext =
'<button type="button" class="btn btn-default btn-sm text-red"><i class="fa fa-ban"></i> Blacklist</button>';
break;
case "4":
blocked = true;
colorClass = "text-red";
fieldtext = "Blocked <br class='hidden-lg'>(regex blacklist)";

Expand All @@ -206,40 +216,34 @@ $(document).ready(function() {
'<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'>(exact blacklist)";
buttontext =
'<button type="button" class="btn btn-default btn-sm text-green"><i class="fas fa-check"></i> Whitelist</button>';
break;
case "6":
blocked = true;
colorClass = "text-red";
fieldtext = "Blocked <br class='hidden-lg'>(external, IP)";
buttontext = "";
break;
case "7":
blocked = true;
colorClass = "text-red";
fieldtext = "Blocked <br class='hidden-lg'>(external, NULL)";
buttontext = "";
break;
case "8":
blocked = true;
colorClass = "text-red";
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)";

Expand All @@ -252,15 +256,13 @@ $(document).ready(function() {
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";
fieldtext = "Unknown (" + parseInt(data[4]) + ")";
buttontext = "";
Expand Down Expand Up @@ -301,43 +303,12 @@ $(document).ready(function() {

// Check for existence of sixth column and display only if not Pi-holed
var replytext,
replyid = parseInt(data[5]);;
switch (replyid) {
case 0:
replytext = "N/A";
break;
case 1:
replytext = "NODATA";
break;
case 2:
replytext = "NXDOMAIN";
break;
case 3:
replytext = "CNAME";
break;
case 4:
replytext = "IP";
break;
case 5:
replytext = "DOMAIN";
break;
case 6:
replytext = "RRNAME";
break;
case 7:
replytext = "SERVFAIL";
break;
case 8:
replytext = "REFUSED";
break;
case 9:
replytext = "NOTIMP";
break;
case 10:
replytext = "upstream error";
break;
default:
replytext = "? (" +data[5] + ")";
replyid = parseInt(data[5]);

if (replyid >= 0 && replyid < replyTypes.length) {
replytext = replyTypes[replyid];
} else {
replytext = "? (" + replyid + ")";
}

replytext += '<input type="hidden" name="id" value="' + replyid + '">';
Expand Down Expand Up @@ -546,8 +517,6 @@ function applyColumnFiltering() {
tableApi.draw();
}

var colTypes = ["time", "query type", "domain", "client", "status", "reply type"];

function showResetButton() {
var button = $("#resetButton");
var text = "";
Expand Down

0 comments on commit efe0244

Please sign in to comment.