Skip to content

Commit

Permalink
Merge pull request #1675 from pi-hole/new/SVCB_HTTPS
Browse files Browse the repository at this point in the history
Add SVCB and HTTPS types
  • Loading branch information
PromoFaux authored Jan 13, 2021
2 parents de75045 + fa2279d commit 136006b
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 37 deletions.
36 changes: 5 additions & 31 deletions api_db.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,40 +120,14 @@ function resolveHostname($clientip, $printIP)
if(!is_bool($results))
while ($row = $results->fetchArray())
{
// Try to resolve host name of this client
$c = resolveHostname($row[3],false);

// Convert query type ID to name
// Names taken from FTL's query type names
switch($row[1]) {
case 1:
$query_type = "A";
break;
case 2:
$query_type = "AAAA";
break;
case 3:
$query_type = "ANY";
break;
case 4:
$query_type = "SRV";
break;
case 5:
$query_type = "SOA";
break;
case 6:
$query_type = "PTR";
break;
case 7:
$query_type = "TXT";
break;
case 8:
$query_type = "NAPTR";
break;
default:
$query_type = "UNKN";
break;
}
// array: time type domain client status upstream destination
$query_type = getQueryTypeStr($row[1]);

// Insert into array
// array: time type domain client status upstream destination
$allQueries[] = [$row[0], $query_type, utf8_encode(str_replace("~"," ",$row[2])), utf8_encode($c), $row[4], utf8_encode($row[5])];
}
}
Expand Down
7 changes: 1 addition & 6 deletions queries.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,7 @@
}
else if(isset($_GET["querytype"]))
{
$qtypes = ["A (IPv4)", "AAAA (IPv6)", "ANY", "SRV", "SOA", "PTR", "TXT", "NAPTR", "MX", "DS", "RRSIG", "DNSKEY", "NS", "OTHER"];
$qtype = intval($_GET["querytype"]);
if($qtype > 0 && $qtype <= count($qtypes))
$showing .= " ".$qtypes[$qtype-1]." queries";
else
$showing .= " type ".$qtype." queries";
$showing .= " type ".getQueryTypeStr($_GET["querytype"])." queries";
}
else if(isset($_GET["domain"]))
{
Expand Down
41 changes: 41 additions & 0 deletions scripts/pi-hole/php/func.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,4 +405,45 @@ function returnError($message = "", $json = true)
}
}

function getQueryTypeStr($querytype)
{
$qtype = intval($querytype);
switch ($qtype) {
case 1:
return "A (IPv4)";
case 2:
return "AAAA (IPv6)";
case 3:
return "ANY";
case 4:
return "SRV";
case 5:
return "SOA";
case 6:
return "PTR";
case 7:
return "TXT";
case 8:
return "NAPTR";
case 9:
return "MX";
case 10:
return "DS";
case 11:
return "RRSIG";
case 12:
return "DNSKEY";
case 13:
return "NS";
case 14:
return "OTHER";
case 15:
return "SVCB";
case 16:
return "HTTPS";
default:
return "UNKN (".$qtype.")";
}
}

?>

0 comments on commit 136006b

Please sign in to comment.