mirror of
https://github.com/pi-hole/web.git
synced 2026-04-24 02:39:25 +01:00
Add name resolution capabilites (with caching) for web interface
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
@@ -138,4 +138,30 @@ function disconnectFTL($quiet=true)
|
||||
echo "OK.\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
$clients = [];
|
||||
function resolveHostname($c)
|
||||
{
|
||||
if(array_key_exists($c, $clients))
|
||||
{
|
||||
// Entry already exists
|
||||
$c = $clients[$c];
|
||||
}
|
||||
else
|
||||
{
|
||||
if(filter_var($c, FILTER_VALIDATE_IP))
|
||||
{
|
||||
// Get host name of client and convert to lower case
|
||||
$c = strtolower(gethostbyaddr($c));
|
||||
}
|
||||
else
|
||||
{
|
||||
// This is already a host name
|
||||
$c = strtolower($c);
|
||||
}
|
||||
// Buffer result
|
||||
$clients[$c] = $c;
|
||||
}
|
||||
return $c;
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user