Don't want IPs in Query Log output

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2018-03-05 16:35:42 +01:00
parent 9e5eba4036
commit 1ec38e3a79
2 changed files with 13 additions and 8 deletions

View File

@@ -155,7 +155,7 @@ if ((isset($_GET['topClients']) || isset($_GET['getQuerySources'])) && $auth)
foreach($return as $line)
{
$tmp = explode(" ",$line);
$top_clients[resolveHostname($tmp[2])] = intval($tmp[1]);
$top_clients[resolveHostname($tmp[2],true)] = intval($tmp[1]);
}
$result = array('top_sources' => $top_clients);
@@ -177,7 +177,7 @@ if (isset($_GET['getForwardDestinations']) && $auth)
foreach($return as $line)
{
$tmp = explode(" ",$line);
$forward_dest[resolveHostname($tmp[2])] = floatval($tmp[1]);
$forward_dest[resolveHostname($tmp[2],true)] = floatval($tmp[1]);
}
$result = array('forward_destinations' => $forward_dest);
@@ -226,7 +226,7 @@ if (isset($_GET['getAllQueries']) && $auth)
foreach($return as $line)
{
$tmp = explode(" ",$line);
$tmp[3] = resolveHostname($tmp[3]);
$tmp[3] = resolveHostname($tmp[3],false);
array_push($allQueries,$tmp);
}

View File

@@ -139,17 +139,19 @@ function disconnectFTL($quiet=true)
}
}
$clients = [];
function resolveHostname($clientip)
$clients = array();
function resolveHostname($clientip, $printIP)
{
if(array_key_exists($clientip, $clients))
{
// Entry already exists
$clientname = $clients[$clientip];
return $clientname."|".$clientip;
if($printIP)
return $clientname."|".$clientip;
return $clientname;
}
if(filter_var($clientip, FILTER_VALIDATE_IP))
else if(filter_var($clientip, FILTER_VALIDATE_IP))
{
// Get host name of client and convert to lower case
$clientname = strtolower(gethostbyaddr($clientip));
@@ -161,6 +163,9 @@ function resolveHostname($clientip)
}
// Buffer result
$clients[$clientname] = $clientip;
return $clientname."|".$clientip;
if($printIP)
return $clientname."|".$clientip;
return $clientname;
}
?>