mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-13 00:07:26 +00:00
Reporting: Unbound DNS - minor endpoint cleanups (error and input handling)
This commit is contained in:
parent
5ac34a84d5
commit
fc7e1ddddf
@ -51,22 +51,23 @@ class OverviewController extends ApiControllerBase
|
||||
];
|
||||
}
|
||||
|
||||
public function RollingAction($timeperiod, $clients = false)
|
||||
public function RollingAction($timeperiod, $clients = '0')
|
||||
{
|
||||
$this->sessionClose();
|
||||
// Sanitize input
|
||||
$interval = preg_replace("/^(?:(?!1|12|24).)*$/", "24", $timeperiod) == 1 ? 60 : 600;
|
||||
$type = $clients ? 'clients' : 'rolling';
|
||||
$interval = filter_var($timeperiod, FILTER_SANITIZE_NUMBER_INT) == 1 ? 60 : 600;
|
||||
$type = !empty($clients) ? 'clients' : 'rolling';
|
||||
$response = (new Backend())->configdpRun('unbound qstats ' . $type, [$interval, $timeperiod]);
|
||||
return json_decode($response, true);
|
||||
return json_decode($response, true) ?? [];
|
||||
}
|
||||
|
||||
public function totalsAction($maximum)
|
||||
{
|
||||
$this->sessionClose();
|
||||
$max = preg_replace("/^(?:(?![0-9]).)*$/", "10", $maximum);
|
||||
$response = (new Backend())->configdpRun('unbound qstats totals', [$max]);
|
||||
$response = (new Backend())->configdpRun('unbound qstats totals', [$maximum]);
|
||||
$parsed = json_decode($response, true);
|
||||
if (!is_array($parsed)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$nodes = (new \OPNsense\Unbound\Unbound())->getNodes();
|
||||
/* Map the blocklist type keys to their corresponding description */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user