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

Improve loop for getAllQueries from FTL's memory #2163

Merged
merged 5 commits into from
Apr 13, 2022
Merged
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
39 changes: 27 additions & 12 deletions api_FTL.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,19 +306,34 @@
if (array_key_exists("FTLnotrunning", $return)) {
$data = array("FTLnotrunning" => true);
} else {
$allQueries = array();
foreach ($return as $line) {
$tmp = str_getcsv($line," ");
// UTF-8 encode domain
$tmp[2] = utf8_encode(str_replace("~"," ",$tmp[2]));
// UTF-8 encode client host name
$tmp[3] = utf8_encode($tmp[3]);
array_push($allQueries,$tmp);
// Start the JSON string
echo '{"data":[';
$first = true;

foreach($return as $line) {

// Insert a comma before the next record (except on the first one)
if (!$first) {
echo ",";
} else {
$first = false;
}

$row = str_getcsv($line," ");
// UTF-8 encode domain
$domain = utf8_encode(str_replace("~"," ",$row[2]));
// UTF-8 encode client host name
$client = utf8_encode($row[3]);

// Insert into array and output it in JSON format
// array: time type domain client status dnssecStatus reply response_time CNAMEDomain regexID upstream destination EDE
echo json_encode([$row[0], $row[1], $domain, $client, $row[4], $row[5], $row[6], $row[7], $row[8], $row[9], $row[10], $row[11]]);
}

$result = array('data' => $allQueries);
$data = array_merge($data, $result);
}
// Finish the JSON string
echo ']}';
// exit at the end
exit();
}
}

if (isset($_GET["recentBlocked"]) && $auth) {
Expand Down