mirror of
https://github.com/pi-hole/web.git
synced 2024-12-06 19:36:21 +01:00
Add SVCB and HTTPS types and reduce code duplication
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
+5
-31
@@ -120,40 +120,14 @@ if (isset($_GET['getAllQueries']) && $auth)
|
||||
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])];
|
||||
}
|
||||
}
|
||||
|
||||
+1
-6
@@ -59,12 +59,7 @@ else if(isset($_GET["forwarddest"]))
|
||||
}
|
||||
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"]))
|
||||
{
|
||||
|
||||
@@ -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.")";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user