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 SVCB and HTTPS types #1675

Merged
merged 1 commit into from
Jan 13, 2021
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
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.")";
}
}

?>